Chopping up pixmaps and making images

BlitzMax Forums/BlitzMax Programming/Chopping up pixmaps and making images

Robert Cummings(Posted 2006) [#1]
Hi,

I plan to do the following but I need your help please:

1) load in a pixmap with alpha channel, create another pixmap and draw the loaded pixmap back to it, with rotation and scaling (pre-rendering some frames), then finally save the new pixmap as a png with alpha.

2) load in a pixmap and create an image. I then copy bits from the pixmap to the image to create a single image with lots of different bits of the pixmap in it (think single surface)... then free the pixmap.

Are these two things achievable? I really hope they are. If you can help then I would really appreciate it. I just don't know how to do these actions. I am not looking for entire source, just magic commands and techniques I can work with.


N(Posted 2006) [#2]
1) Not sure how to handle that.

2) Use pixmap.Window( cx, cy, cw, ch ).Paste( destPixmap, x, y )


Robert Cummings(Posted 2006) [#3]
Thanks noel.

Regarding point 2, I want to copy lots of bits of a pixmap to the same image:TImage, not another pixmap.


N(Posted 2006) [#4]
Well Pixmap.Window creates a new pixmap, so you could just do pixmap.Window( x, y, w, h ).Paste( pixmap, x, y ).


ImaginaryHuman(Posted 2006) [#5]
You could lock an image and then use .paste to put pieces onto it, but there's really not need to use images if you do it all in pixmaps.


Robert Cummings(Posted 2006) [#6]
thanks so I use lockimage, then mypixmap.paste to copy it into the image?

I apologise but I need it explained to me because at the moment I'm very confused.


assari(Posted 2006) [#7]
Check-out the codes by Grisu here
this part paste a smaller pixmap onto a larger one
If FileType("iconstrip.png")=0 Then   
 Global Fullpixmap:TPixmap=CreatePixmap(((MAXFOLGEN)*ICONSIZE),ICONSIZE,PF_BGR888,1) 
 Local tmppixmap:TPixmap 

 For Local i:Int=0 To MAXFOLGEN-1  
    tmppixmap=LoadPixmap("0.jpg")  '96x96 Pixel icon!
    fullpixmap.paste(ResizePixmap(tmppixmap,ICONSIZE-2,ICONSIZE-2),1+i*ICONSIZE,1)
 Next 
 SavePixmapPNG(fullpixmap, "iconstrip.png",9 )
EndIf 



tonyg(Posted 2006) [#8]
Do all your pixmap manipulation then
image:TImage=loadimage(pixmap).
However, getting a scaled rotated image/pixmap into another image is either slow (draw it to backbuffer then grabpixmap) or complicated by creating a 'rendertarget'.
You can't do this with native Bmax.


Robert Cummings(Posted 2006) [#9]
I only need to get a rotated pixmap into another pixmap, this is absolutely essential... is it missing?

I do need to copy 'normal' pixmaps into a larger image though if at all possible.


dynaman(Posted 2006) [#10]
> I only need to get a rotated pixmap into another pixmap, this is absolutely essential... is it missing?


Yes, the only way to do it is to draw the rotated image on the screen and then grab that onto the pixmap - and then go on with drawing the screen you want the use to see before doing the flip. (unless something new has been added in the last couple releases)


tonyg(Posted 2006) [#11]
..or use Indiepath's Render2Texture.
What's annoying for me is Imagebuffers were superb in B2D/B3D (even by BRL's admission) but overlooked in BMax. It's been proved possible but not in native Bmax because, I think, it uses texture management (at least for DX).
Oh, and I can't seem to get pixmap.paste to work the way it used to either.
<edit> Ooops, can get it to work but it ignores masking.
That's why I went through this convoluted scenario...



Robert Cummings(Posted 2006) [#12]
hardware isn't available on this machine - thanks :)

So I need a genuine software solution...


tonyg(Posted 2006) [#13]
That code can be used with just pixmaps. Sub the loadimage with loadpixmap and use them directly rather than lockimage pixmaps.