Blitting

BlitzMax Forums/BlitzMax Programming/Blitting

verfum(Posted 2005) [#1]
Hi,
If I load a large bitmap, say 3000x3000. Can I blit an arbitrary rectangle (say, 640x480) from this bitmap onto the back buffer?
i.e. I want a function that takes a source image, a start point, width, height and back-buffer destination point.
like this...
blit(source:TImage, x#, y#, width#, height#, x2#, y2#)

Cheers


ImaginaryHuman(Posted 2005) [#2]
look at glDrawPixels() and use a `skip` value to skip the undrawn pixels from each row


tonyg(Posted 2005) [#3]
There's drawimagerect
and
drawimageblock
and using setviewport


taxlerendiosk(Posted 2005) [#4]
tonyg: Images are textured quads, he wants to directly draw pixels from a pixmap to the screen buffer.


deps(Posted 2005) [#5]
denzilquixode: Can't find anything in his post about drawing pixels only. And why would he? That would be really slow.


taxlerendiosk(Posted 2005) [#6]
Because he used the term "blitting", which means moving a block of memory. I assumed he wouldn't use the term unless he knew what he was doing and what he wanted, otherwise he'd just call it drawing part of the image or something.

As for why he would do it, I don't know exactly, but there are examples. Like a Worms-like game, where you want destructable landscape.


deps(Posted 2005) [#7]
I stand corrected.


TartanTangerine (was Indiepath)(Posted 2005) [#8]
Wait for the new version, it'll be in there.


ImaginaryHuman(Posted 2005) [#9]
glDrawPixels() might be faster than uploading the pixmap to an image and drawing the image.


taxlerendiosk(Posted 2005) [#10]
Doesn't the current DrawPixmap routine just use glDrawPixels anyway?


LarsG(Posted 2005) [#11]
Wait for the new version, it'll be in there.


Got inside information?
Something else you want to share with us?!? :D


TartanTangerine (was Indiepath)(Posted 2005) [#12]
Only what I've gleaned from these forums.


verfum(Posted 2005) [#13]
Hi,

Thanks for replies!
As denzilquixode mentions, I want a destuctible landscape.

The entire game map is one bitmap which I need to modify in ram before it is displayed.

What's the best method to accomplish this?

I guess to be able to draw to my bitmap it will need to be a PixMap? But how do you blit the pixmap to the back buffer? Is this fast?

I've heard that LoadImage loads into ram and then DrawImage creates an opengl quad - don't think this is what I want.

I'm new to blitzmax - last time I used blitz it was on the Amiga and my scroller used 16*16 blocks ;P

All I want to do is know how do do things the old way, but with larger mapblocks (300x300).


verfum(Posted 2005) [#14]
I've looked at what some people have said, and they say that DrawPixmap is slow as it uses CPU to draw to the video backbuffer directly and has no opengl acceleration.

Am I right in thinking that I could load a whole load on TImages using LoadImage and these would be loaded into RAM and then they only enter the video ram when you call DrawImage?

If this is the case, then how can I modify a TImage before I call DrawImage? I need my background to be dynamically updated - like the skidmarks of a car.


QuietBloke(Posted 2005) [#15]
Id be interested too. I was mucking about with knocking up a space invaders clone and to cause damage on the shields I ended up locking the image... plotting a bunch of bloack pixels onto it and unlocking. Not too bad when doing damage to a shield but drawing anything much more complex would be painful.


Dubious Drewski(Posted 2005) [#16]
If you need to lock a TImage for editing via read/writepixel,
be sure to do it rarely and only on small-sized images.

Lockimage converts a TImage(Video Ram: fast) to a pixmap
(System Ram: Slooow). Am I right?

As far as I know, Bmax has no built-in way of editing VideoRam
data. (Though I haven't used OpenGL yet; it might let you)


ImaginaryHuman(Posted 2005) [#17]
Yes DrawPixmap calls glDrawPixels. You could set up a static pixmap within another pixmap, to define the window, then DrawPixmap the static pixmap to the backbuffer. Only thing is, DrawPixmap also probably does an on-the-fly Y-flip, which slows it down.


verfum(Posted 2005) [#18]
"Lockimage converts a TImage(Video Ram: fast) to a pixmap
(System Ram: Slooow). Am I right?"

How slow is this? Could you lock the image, draw to it and then DrawImage each frame?
Assuming the image is around 400x400 pixels.


tonyg(Posted 2005) [#19]
This might help...
Drawbuffer
In non-debug it writes a 255*255 image into a 512*512 background in 1ms