How do I convert an image into a pixmap?

BlitzMax Forums/BlitzMax Beginners Area/How do I convert an image into a pixmap?

Grey Alien(Posted 2006) [#1]
Hi I must be being dumb here but I can't see a way to convert an image into a pixmap in code. Sure you can reload the image but can't you do a straight conversion somehow?

thanks.


H&K(Posted 2006) [#2]
I must admit I always paste it to a screen and them grab it back. But what about LockImage?


Dreamora(Posted 2006) [#3]
Yupp, lockimage is the way to go.


Jesse(Posted 2006) [#4]
do you mean something like this :



H&K(Posted 2006) [#5]
@Jesse

I thought it had been decided that UnLockImage didnt do anything?


Jesse(Posted 2006) [#6]
I wondered about that but never questioned it. This is the first time I hear about it. Do you know what exactly does lockimage do? does it create a pointer to the image?


Jesse(Posted 2006) [#7]
never mind, I read the thread:
http://www.blitzbasic.com/Community/posts.php?topic=62100#694503

so I guess it is not efficient to draw to an image on the fly.


tonyg(Posted 2006) [#8]
LockImage seems to call image.lock method which calls CreatePixmap returning a pixmap.
<edit> Jesse, you can't draw to an image simply because you can't access its pixels.
Your answer was correct except the writepixel stuff isn't necessary. Simply LoadImage then lockimage to obtain a pixmap. True you'd most likely want to do *something* to it as drawpixmap is much slower than drawimage. Alternatively loadpixmap if you want a pixmap to start with.


Jesse(Posted 2006) [#9]
I was aware about writepixel and how I could load an image and read its content with readpixel. what I didn't know was about loadpixmap because I didn't have any need for it or at least I thought(out sight out of mind). I also had a sligth misunderstanding on how lockimage worked. Now I know. It helps to look at the BRL code but my simple understandig of the language makes it difficult (not impossible) for me to understand it. To prevent my limited time from being wasted in other things (not part of programming) I limit myself to the IDE help syntax until otherwise I run in to problems.
<edit>
and I learned that when when I edit a pixmap from a loaded image I am editing only the pixmap and that before it is drawn it has to be copied back to an image and it is done automatically ( at least thats what I understood).


H&K(Posted 2006) [#10]
@Jesse, Im with you on this, Until that thread whos link you posted I thought that LockImage was allowing me to access a texture (for example), it was only after reading the replies I got on said thread that I realised what waste of preccesor time I had been doing.


Grey Alien(Posted 2006) [#11]
thanks. I needed to use ReadPixel on a Pixmap that was a mask for my game, and I loaded in the Pixmap directly but wondered how to convert an imae. So it seems you can lock the image then read it's pixels (Blitz Plus style).