image vs pixmap

BlitzMax Forums/BlitzMax Beginners Area/image vs pixmap

meems(Posted 2016) [#1]
whats the need to invoke pixmaps in blitzmax when we already had images in blitzplus \ blitz3d?

I'm experienced in using images and atm can't see why i'd ever need a pixmap. It seems entirely redundant.


xlsior(Posted 2016) [#2]
I'm experienced in using images and atm can't see why i'd ever need a pixmap. It seems entirely redundant.


Basically, an image resides in the graphics memory of your video card, while a pixmap resides in your computers normal memory and is uploaded to the videocard when you use a drawpixmap. Those extra steps mean that pixmaps are much slower to draw, but the advantage is that you can modify them after the fact which you can't with images.

So... Unless you need to modify an images after loading it, there would be no reason to ever use pixmaps.


Kryzon(Posted 2016) [#3]
To add to xlsior's, when you load an image from a file all of it happens internally with TPixmaps.
https://github.com/maxmods/brl.mod/blob/master/max2d.mod/image.bmx#L63

The format loaders (PNG, JPEG etc.) load the pixel data into a new TPixmap and then the Max2D module creates a TImage from that pixmap and gives the image to you.

Unless you're writing your own image file loader, generating procedural graphics or some other way of obtaining pixels like downloading them from a server etc., there's no need to use TPixmaps.
When you do need them, they're a convenient object that holds pixel data and is easily convertible to the hardware-accelerated TImages by just doing LoadImage( myPixmap ).