PureBasic ImagePickerGadget() - A Cross-Platform Solution

Share your advanced PureBasic knowledge/code with the community.
User avatar
HeX0R
Addict
Addict
Posts: 1187
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by HeX0R »

With debugger enabled you see the problem:
[ERROR] ImagePickerGadget.pbi (Line: 301)
[ERROR] ResizeGadget(): Maximum supported gadget height is 32767 pixels
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by le_magn »

Hi, this is the list of all files in directory:

Name / Extension / Size / Date / Attributes
https://pastebin.com/DnCf0aES
Image
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

HeX0R wrote: Wed Nov 27, 2024 10:43 pm With debugger enabled you see the problem:
[ERROR] ImagePickerGadget.pbi (Line: 301)
[ERROR] ResizeGadget(): Maximum supported gadget height is 32767 pixels
Thanks @HeXOR. That clearly needs a handler.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

le_magn wrote: Wed Nov 27, 2024 11:00 pm Hi, this is the list of all files in directory:

Name / Extension / Size / Date / Attributes
https://pastebin.com/DnCf0aES
Thank you for that. It appears to contain over 2000 JPG and PNG images. This could be the issue, as @HeXOR had pointed out, because the expected height of the canvas to display all the images (even @120px height per image, double-columned) would exceed the 32767 canvas gadget height limitation.

I just tested the scenario myself, and the program crashed once the canvas size exceeded 32767.

But you mentioned that the program did not crash for you? And that you are still able to scroll upwards but not downwards past a quarter of the window?
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

Hi @le_magn. I've just posted an update which includes a fix that might circumvent the issue you're facing. It will now stop loading images once the canvas limitation is reached.

Barring any possibilities of implementing some form of lazy loading or paging, this would be a limitation of the gadget for now.

Please do give it a try and see if it works for you.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by le_magn »

TI-994A wrote: Thu Nov 28, 2024 12:15 am Hi @le_magn. I've just posted an update which includes a fix that might circumvent the issue you're facing. It will now stop loading images once the canvas limitation is reached.

Barring any possibilities of implementing some form of lazy loading or paging, this would be a limitation of the gadget for now.

Please do give it a try and see if it works for you.
yes i tried, a message popup display limit reached not all images loaded etc... but now scroll until the end and up ok
Image
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

le_magn wrote: Thu Nov 28, 2024 12:43 amyes i tried, a message popup display limit reached not all images loaded etc... but now scroll until the end and up ok
Thanks for the confirmation, @le_magn. Glad to hear that. :D

I'm still working on some additional enhancements to the gadget, so please look out for updates.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by AZJIO »

Code: Select all

picker(index)\images(imgCount)\imgNum = LoadImage(#PB_Any, picker(index)\imagesFolder + DirectoryEntryName(directory))

Code: Select all

[21:49:18] [WARNING] ImagePickerGadget.pbi (Line: 312)
[21:49:18] [WARNING] The specified file does not exist.
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

AZJIO wrote: Thu Nov 28, 2024 5:51 pm

Code: Select all

picker(index)\images(imgCount)\imgNum = LoadImage(#PB_Any, picker(index)\imagesFolder + DirectoryEntryName(directory))

Code: Select all

[21:49:18] [WARNING] ImagePickerGadget.pbi (Line: 312)
[21:49:18] [WARNING] The specified file does not exist.
Hi @AZJIO. Thanks for reporting this.

Would you be able to debug and check what file is causing that error? Because it is returned by the ExamineDirectory() routine from your input folder

This LoadImage() statement is called within a conditional block that filters through only files with the allowable image extensions. So it could possibly be a corrupted image file.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by AZJIO »

I added "\" and it worked for me. You need to check that the path ends with "\"

Code: Select all

Debug picker(index)\imagesFolder + "\" + DirectoryEntryName(directory)
picker(index)\images(imgCount)\imgNum = LoadImage(#PB_Any, picker(index)\imagesFolder + "\" + DirectoryEntryName(directory))  
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

AZJIO wrote: Thu Nov 28, 2024 9:56 pm I added "\" and it worked for me. You need to check that the path ends with "\"

Code: Select all

Debug picker(index)\imagesFolder + "\" + DirectoryEntryName(directory)
picker(index)\images(imgCount)\imgNum = LoadImage(#PB_Any, picker(index)\imagesFolder + "\" + DirectoryEntryName(directory))  
Thanks @AZJIO.

I supposed that the accuracy of the folder name should be handled by the user. PureBasic's native functions, like get temporary and current directories, return the values with the trailing path separator.

Nevertheless, it's an absolutely possible oversight, so I've added a validation for that. I'll be crediting you for this fix, btw. :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

HeX0R wrote: Wed Nov 27, 2024 10:43 pm With debugger enabled you see the problem:
[ERROR] ImagePickerGadget.pbi (Line: 301)
[ERROR] ResizeGadget(): Maximum supported gadget height is 32767 pixels
Hello again, @HeXOR. Thanks for reporting this bug. Please do note that I have credited you for this fix in the latest update. :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

I've just posted another update to the ImagePickerGadget(). This update changes some of the earlier parameter names, and adds some new ones, in addition to a few bug fixes.

Some of the new features include:
  • support for images of different sizes and orientations
  • auto-rotating preview window to display portrait & landscape images
  • thumbnails with options to display borders, background, and titling
  • titling derived from image file names, and sized in proportion to the thumbnail
  • busy notification window when loading large number of images
Image

I thank all of you who have assisted in the initial testing of this gadget, and hope to receive your continued support. :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
fromVB
User
User
Posts: 82
Joined: Sun Jul 29, 2012 2:27 am

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by fromVB »

Wow! You've outdone yourself TI-994A! :shock:

I've not used PB in a while now but I could have really used this tool a few years back.

I quickly tested in with the free demo version of PB and was surprised that it worked. Keep up the magnificent work. :)
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PureBasic ImagePickerGadget() - A Cross-Platform Solution

Post by TI-994A »

fromVB wrote: Sat Nov 30, 2024 7:56 am Wow! You've outdone yourself TI-994A! :shock:

I've not used PB in a while now but I could have really used this tool a few years back.

I quickly tested in with the free demo version of PB and was surprised that it worked. Keep up the magnificent work. :)
Hi @fromVB, and thank you for your kind words and feedback.

I'm glad that you find it useful, even if you may not be using it. :lol:

I just checked, and you're right; it does work with the demo version of PureBasic. I didn't expect it to work, at least not on macOS, because there are some CocoaMessage() API calls used.

That's another feature then, I suppose. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply