Change size of ListIconGadget image preview?

Everything else that doesn't fall into one of the other PB categories.
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Change size of ListIconGadget image preview?

Post by Kaiser »

Yup. I have a folder full of screenshots and want to see them in thumbnails. Since they're in TGA I can't use WinAPI and make an image_list_thing to show them because Windows XP doesn't get those thumbnails natively (in thumbs.db) so I have to load them using the TGAImageDecoder. Ok, no problem, but the size of the ListIcon preview cannot be changed, and I can't see the screenshots very well in 32x32... not to mention if I try still, I'll get the first 32x32 top-left region of the image, and that's not the idea.

In other words, I'm making myself a TGA thumbnail viewer, but the limited size of the ListIcon preview does not let me.... can someone lend me a hand here please? :)
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post by Kaiser »

:bump: :(?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

No.
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post by Kaiser »

No... what o0......

okay, don't lend me a hand.... but a leg? xD
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

The size of icons in the ListIcon gadget is 32x32 pixels and you can't make it larger.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Special for you:

Code: Select all

EnableExplicit

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

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

Global ScrollArea = ScrollAreaGadget(#PB_Any, 0, 0, 512, 384, 512, 384, 30)

; Load images
Procedure LoadImages()
  Define Dir.s = "C:\Documents and Settings\Trond\Mine Dokumenter\Mine bilder\"
  Define Image.l
  While CountList(Images())
    FreeImage(Images()\ImageNumber)
    DeleteElement(Images(), 1)
  Wend
  If ExamineDirectory(0, dir, "*.bmp")
    While NextDirectoryEntry(0)
      Image = LoadImage(#PB_Any, Dir + DirectoryEntryName(0))
      ResizeImage(Image, THUMBNAILSIZE, THUMBNAILSIZE, #PB_Image_Raw)
      If Image
        AddElement(Images())
        Images()\ImageNumber = Image
        Images()\Filename = Dir + DirectoryEntryName(0)
        Images()\Gadget = ImageGadget(#PB_Any, 0, 0, 64, 64, ImageID(Images()\ImageNumber))
      Else
        Debug "Invalid image: " + DirectoryEntryName(0)
      EndIf
    Wend
  Else
    Debug "Can't examine directory"
  EndIf
EndProcedure

; Line up images
Procedure LineUpThumbnails()
  Protected I
  Protected X, Y
  Protected OffsetX = 25, OffsetY = 25
  Protected SpaceX = 15, SpaceY = 15
  Protected Width = GadgetWidth(ScrollArea)
  ForEach Images()
    With Images()
      ResizeGadget(\Gadget, X + OffsetX, Y + OffsetY, #PB_Ignore, #PB_Ignore)
    EndWith
    If (X + ThumbnailSize*2 + OffsetX*2 + SpaceX + GetSystemMetrics_(#SM_CXHTHUMB)) > Width
      X = 0
      Y + ThumbnailSize + OffsetY
    Else
      X + ThumbnailSize + OffsetY
    EndIf
  Next
  SetGadgetAttribute(ScrollArea, #PB_ScrollArea_InnerHeight, Y + ThumbnailSize + OffsetY*2)
  SetGadgetAttribute(ScrollArea, #PB_ScrollArea_InnerWidth, Width-GetSystemMetrics_(#SM_CXHTHUMB)-4)
EndProcedure

LoadImages()
HideWindow(0, 0)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_SizeWindow
      ResizeGadget(ScrollArea, 0, 0, WindowWidth(0), WindowHeight(0))
      LineUpThumbnails()
  EndSelect
ForEver




















Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post by Kaiser »

I love specials ;)

No really, thanks a lot :O it does exactly what I wanted xD... I think I can adapt it to what I need ;) gotta study it a bit, thanks a bunch ^_^ :D
Post Reply