Is there a way to put image frames together in one

Blitz3D Forums/Blitz3D Programming/Is there a way to put image frames together in one

dman(Posted 2010) [#1]
Hi, I am trying to put images together using grab image and draw image with frames.

I grab the images in frames then want to put all the frames together in one buffer and one frame then scroll the whole buffer.


is it possible or another way of doing it?

please help.

thank you.


Warner(Posted 2010) [#2]
You can use CopyRect to copy from one image buffer onto another.


dman(Posted 2010) [#3]
I don't think that will work because you have to use the CreateImage

with limited screen size. I need it pass the screen size.

I grab a section of screen 0 to 640 for each frame, ex. about 23 frames. then I use DrawImage and go through each frame.

I want to just take the grabbed frames and join them together in a buffer and use it with DrawImage to scroll.

HERE ARE SOME EXAMPLE CODE:





PowerPC603(Posted 2010) [#4]
I tried creating a very large image (640 * 24, 480) and it didn't give any errors, even when drawing the image onscreen every frame.

This example program creates one image of size 640 x 480 (img).
This image is cleared with a random color, the frame-number of written to it, and this image is copied 24 times to the large image (limg), which is of size (640*24) x 480. They are copied next to eachother.

So the final "limg" image has 24 different colored areas next to eachother, all of size 640 x 480.

Finally, in the main loop, the "limg" image is drawn and shifts to the left.

Graphics3D 640, 480, 0, 2
SetBuffer BackBuffer()

width = 640
height = 480
frames = 24

SeedRnd MilliSecs()

img = CreateImage(width, height)
limg = CreateImage(width * frames, height)

SetBuffer ImageBuffer(img)

For i = 1 To frames
	ClsColor Rand(0, 255), Rand(0, 255), Rand(0, 255)
	Cls
	Text 2, 2, "Fr. " + i
	CopyRect 0, 0, width, height, (i - 1) * width, 0, ImageBuffer(img), ImageBuffer(limg)
Next

SetBuffer BackBuffer()

ClsColor 0, 0, 0

While Not KeyHit(1)
	Cls
	loop = loop + 1
	DrawImage limg, loop * (-1), 0
	Flip
Wend

WaitKey()
End


So, creating and using images much larger than the screensize is surely possible.

You can edit the size of the images by adjusting the width and height variables.
You can also edit the number of frames.
I tried using 100 frames, which still works. But it was alot slower to draw, as the image was so big (64000 x 480).
So, be careful when using such large images, as Blitz3D will draw the entire image, even when most of the image is outside the screen.

So, if you have 24 separate images, you can load them into "img" instead of clearing the image with a random color and the code generates your large image.

EDIT: I tried going up further, but when I used 103 frames, I got a MAV, while using 102 frames worked like a charm.

I tried creating an image of 65535 x 480, drawing it and it worked. With a size of 65536 x 480, MAV popped up on DrawImage.
I tried upping the y-size from 480, and it failed when using an image of size 65535 x 5333. (65535 x 5332 still worked).

The largest square image I created succesfully was 18694 x 18694 pixels.
It failed on 18695 x 18695.


dman(Posted 2010) [#5]
Hi PowerPc, I tried the code. It do not go to the end of the buffer, it stops about half way.

Is there away to use the peek and poke commands to do same but copy the whole buffer?


thanks


Warner(Posted 2010) [#6]
I can't answer your question, because I have no idea, but I think indeed creating such large images could cause problems with compatibility. Maybe you should rethink your approach on this? You could line up smaller images side-by-side, and scroll those. This as well creates room to optimisation: images that are not in view can be skipped from drawing.


_PJ_(Posted 2010) [#7]
Why not use a secondary image buffer (or the screen buffer) to DrawImageRect the two consecutive, current image frames side by side? You only ever need a maximum of 2 images in memory this way.