LOTS of Icons and Listboxes
BlitzMax Forums/BlitzMax Beginners Area/LOTS of Icons and Listboxes
| ||
| Hi! Is there a way to load icons for listboxentries via single files for each icon used? Is it possible to use icons bigger than 16x16 pixel? I can't create a-mile-long image with all icons inside and load them via "LoadIconStrip". :( Thanks, Grisu |
| ||
| The number of icons in an iconstrip is determined by dividing the image width by its height. Tried it with 384*32 and it loads icons as 32*32. Basically, they have to be in one line image. What error are you getting? Can't find a way to load icons from seperate files. |
| ||
| The problem is that depending on your graphics card the images may get corrupted. I made the same experience with BlitzPlus... Also directx itself has some maximum image size limit. Edit: And I'd like to be able to change certain icons during runtime. |
| ||
| oh.. and its a pain to work in a very long image in photoshop. |
| ||
| LoadIconStrip uses pixmaps not images so there should be no theoretical limits. If there is it needs fixing so pls send me an example png/bmp that breaks LoadIconStrip. If you want more flexibility you could create the pixmap yourself and then use loadpixmap and pixmap.paste to add / modify individual icons, calling LoadIconStrip(pixmap) and SetGadgetIconStrip after to refresh your gadgets. |
| ||
| Thanks for the help skidracer. Though I'm not 100% how to do this in bmx. :( First, I create a full but empty iconstrip pixmap Global Fullpixmap:TPixmap=CreatePixmap((MAXGADGETS*32),32,PF_RGBA8888) In a for i=0 to MAXGADGETS-1 loop I then... 1. Load the images into a temp pixmap tmppixmap=LoadPixmap("Incbin::./Media/"+i+".jpg") 2. Size the image down to the needed icon size (e.g. 32x32): ResizePixmap(tmppixmap,32,32) 3. But how do I paste / copy this tmp pixmap into the full one? At the position I need (i.e. i*32 as x value) fullpixmap.paste(tmppixmap,0,0) is not right... At the end I load the full iconpixmap and set it to the lsitbox gadget: Local IconStrip:TIconStrip=LoadIconStrip(fullpixmap) SetGadgetIconStrip(ListBox, IconStrip) Finally I can add gadgets to the listbox displaying the icons: For Local i=0 To MAXFGADGETS-1 AddGadgetItem ListBox, i,0,i Next |
| ||
| Grisu, You can also use good old fashion read, writepixels. If you need some code there's one here Making a MaxGUI Application: StripAnimMakerLite Part 7b - Capturing Image to AnimStrip |
| ||
| Isn't read/writepixel really SLOW? I need to get 300 images+... so simply drawing/copying the icon image into the strip should be much faster! |
| ||
| target_pixmap.paste(source_pixmap,x,y) P.S. Bmax read/writepixel is pretty fast. <edit> Quick and dirty (obviously you can do it all in a single loop).
Graphics 640,480
Const maxgadgets=4
pix_target:TPixmap=CreatePixmap((maxgadgets)*32,32,PF_RGBA8888)
Local pix_source:TPixmap[4]
pix_source[0]=LoadPixmap("pix1.png")
pix_source[1]=LoadPixmap("pix2.png")
pix_source[2]=LoadPixmap("pix3.png")
pix_source[3]=LoadPixmap("pix4.png")
For x = 0 To maxgadgets-1
pix_target.paste(pix_source[x],x*32,0)
Next
DrawPixmap pix_target,0,0
For x = 0 To maxgadgets-1
DrawPixmap pix_source[x],x*32,32
Next
Flip
WaitKey()
Local MyWindow:TGadget=CreateWindow("ListBox Example", 200,200,320,240)
Local ListBox:TGadget=CreateListBox(10,10,200,100,MyWindow)
Local IconStrip:TIconStrip=LoadIconStrip(pix_target)
SetGadgetIconStrip(ListBox, IconStrip)
AddGadgetItem ListBox, "This is my first list item",0,1
AddGadgetItem ListBox, "This is my second list item",0,3
Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Forever
|
| ||
| Thanks TonyG... works now... at last.... And is fast enough for my needs... :)))))))))))))))) |