Whats the best way to copy a pixmap to an image including the alpha channel?.
Pixmap to Image?
BlitzMax Forums/BlitzMax Beginners Area/Pixmap to Image? Well well, wiebo the wit on irc just says the magic words
"Look at LoadAnimImage, it can load from a pixmap", lo and behold, hes correct!. Looks like the same for just plain old LoadImage too!
Talk about RTFM! (read the f**king manual)
"Look at LoadAnimImage, it can load from a pixmap", lo and behold, hes correct!. Looks like the same for just plain old LoadImage too!
Talk about RTFM! (read the f**king manual)
I did something like this:
img:TPixmap=LoadPixmap("incbin::ball.png") 'load the pixmap from the inbin'd image file wid=img.width 'get width of pixmap hig=img.height 'get height of pixmap If img.format<>PF_RGBA8888 Then img=ConvertPixmap( img,PF_RGBA8888 ) 'Make sure image format is in the format needed for OpenGL to render it properly Local psource:Byte Ptr 'define pointer for source pixmap data location psource=PixmapPixelPtr(img,0,0) 'get source pixmap data location Global psize:Int=wid*hig*4 '4 bytes per pixel assuming RGBA8888 format pixmap txtri:TImage=CreateImage(wid,hig,1,iflags|DYNAMICIMAGE) 'create dummy image in case we want to do realtime conversion between pixmaps and images/textures txtrp:TPixmap=LockImage(txtri,0,False,True) 'Lock our dummy image so we can draw to it pdest=PixmapPixelPtr(txtrp,0,0) 'Set our destination pointer to the image's pixmap MemCopy(pdest,psource,psize) 'Copy the pixels from the pixmap in memory to the image/texture's pixmap UnlockImage(txtri) 'Let the image be rendered now DrawImage txtri,objpos[o,0],objpos[o,1] 'Render the image/texture
There are also some OpenGL functions that you can use to write pixels, read pixels, convert pixel formats, and create textures (images) out of pixmaps. These are what BlitzMax's higher-level commands are based on. But then you would need to know how to set up the rest of the OpenGL environment, draw vertices and bind textures etc.