It is currently Wed Oct 23, 2019 7:31 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [4.0 final] ImageGadget image messes up
PostPosted: Sat May 13, 2006 11:20 am 
Offline
Always Here
Always Here

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7439
Location: Norway
There appears to be a bug with image gadgets. Use the code below and make sure the Dir variable contains the path to a directory with exactly four png images.

Edit: You can use any image format, but the problem is easier to reproduce with exactly four images (even though it happens with other numbers) and I happened to have a directory with exactly four png images. End of edit.

You should see them resized to 128*128 after each other:
Code:
------
|ABCD|
|    |
------

Slowly resize the window so that it becomes smaller in width (grab right side of window and drag). First the image at the right pops down to a new row.
Code:
-----
|ABC|
|D  |
-----


Continue dragging to make the window even smaller. When the next image goes down to the next row it changes the displayed image:
Code:
----
|AB|
|CC|
----
Now tell me, where did image D go?

When the image gadget is redrawn image D reappears.

Code:
EnableExplicit

UsePNGImageDecoder()

Global ThumbnailSize = 128
Structure PREVIEWIMAGE
  ImageNumber.l
  Gadget.l
EndStructure
Global NewList Images.PREVIEWIMAGE()

OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
CreateGadgetList(WindowID(0))

; Load images
Procedure LoadImages()
  Protected Dir.s = "C:\Documents and Settings\Trond\Mine Dokumenter\Source\Projects 4\Photoon\Images\Birds\"
  ExamineDirectory(0, dir, "*.png")
  While NextDirectoryEntry(0)
    AddElement(Images())
    Images()\ImageNumber = LoadImage(#PB_Any, Dir + DirectoryEntryName(0))
    ResizeImage(Images()\ImageNumber, THUMBNAILSIZE, THUMBNAILSIZE, #PB_Image_Raw)
    Images()\Gadget = ImageGadget(#PB_Any, 0, 0, 64, 64, ImageID(Images()\ImageNumber))
  Wend
EndProcedure

; Line up images
Procedure LineUpThumbnails()
  Protected X, Y
  Protected Width = WindowWidth(0)
  ForEach Images()
    ResizeGadget(Images()\Gadget, X, Y, #PB_Ignore, #PB_Ignore)
    If (X + ThumbnailSize*2) > Width
      X = 0
      Y + ThumbnailSize
    Else
      X + ThumbnailSize
    EndIf
  Next
EndProcedure

LoadImages()

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_SizeWindow
      LineUpThumbnails()
  EndSelect
ForEver


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 14, 2006 11:54 am 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1143
Location: Germany
confirmed as bug.

this shows up the images correct :

Code:
; Line up images
Procedure LineUpThumbnails()
  Protected X, Y
  Protected Width = WindowWidth(0)
  ForEach Images()
    ResizeGadget(Images()\Gadget, X, Y, #PB_Ignore, #PB_Ignore)
    If (X + ThumbnailSize*2) > Width
      X = 0
      Y + ThumbnailSize
    Else
      X + ThumbnailSize
    EndIf
    InvalidateRect_(GadgetID(Images()\Gadget),0,1)
  Next
EndProcedure


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye