Pixmap, what exactly are they?

BlitzMax Forums/BlitzMax Beginners Area/Pixmap, what exactly are they?

u2o(Posted 2006) [#1]
I have seen posts refering to pixmaps and was wondering exactly what they are?

I did do a lookup on them, but what I can work out is that they are some sort of viewport that you can display images on, a sort of mask. Is this correct?

Many thanks


Dreamora(Posted 2006) [#2]
Pixmaps are the raw colordata of an image you loaded and used to create textures out of it for TImage


CS_TBL(Posted 2006) [#3]
In the pre-bm days we'd set an imagebuffer to draw onto an image, in bmax you need to:

lock that image:

local PM:TPixmap=LockImage(MyImage)

then draw to the pixmap:

WritePixel PM,x,y,AlphaRedGreenBlue
(typically I do $ff000000|65536*r+256*g+b, also make sure x and y don't go out of range!)

and then unlock the image again:

UnlockImage MyImage

and there's your updated image!


ImaginaryHuman(Posted 2006) [#4]
A pixmap is a bitmap in main memory containing colored pixels. It has the information needed to define the size of the pixmap, the format of the pixel data and some other stuff, plus the pixel data itself.

If you do LoadPixmap(etc) it will load an image file into a pixmap. So then you have the image stored in main memory. It is not at that point viewable without using DrawPixmap() or converting it into an image.

An image is an identical copy of a pixmap, stored in video memory so the video card can render it to the screen with DrawImage() (fast).

Basically, when things get put in video memory the graphics card can work on it, but it can't do anything with stuff in main memory. Because of this divide, pictures in video memory are called textures or images, and pictures in main memory are call pixmaps.


degac(Posted 2006) [#5]
stupid question: is it possibile to 'delete' a pixmap once the image is stored in the VRAM? or it is necessary to bmax to draw object on the screen?


CS_TBL(Posted 2006) [#6]
A pixmap is not really like an instance of an image, it's more like a way to access that image. If you take my example and put it into a function, then the pixmap instance is gone when you return but the image is still there!

(I think :P)


u2o(Posted 2006) [#7]
Thank you everyone, I sort of understand what they are now, but trying not to sound stupid, why would you use a pixmap?

Is it purly because you can manipulate a pixmap and you cannot with an image?

Many thanks


ImaginaryHuman(Posted 2006) [#8]
You can delete a pixmap and still use the image, so long as you made it into an image first. You don't need the pixmap if you have the image.

You can avoid pixmaps altogether if you just LoadImage().


tonyg(Posted 2006) [#9]
That's not strictly true.
Loadimage will create a pixmap. The first drawimage will create a surface from that pixmap and then draw the texture to it and keep it in video RAM until the texturemanager decides to get rid of it (DX anyway not sure about OGL).
U2o, Pixmaps are usefuly because, as you say, they can be maniupulated. However, converted from pixmap to image is not the fastest process in the world.