Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Large image using memblocks

Author
Message
MummyKillerSLO
17
Years of Service
User Offline
Joined: 5th Jul 2009
Location: Object Position Y(ObjChair)
Posted: 17th Dec 2011 19:13
Hello!

How can I make big image using memblocks to put small images together without drawing them and using get image commands? Let say I want to have image 200 x 200 using 10 x 10 tiles?

Happy to having and using DarkBASIC Professional...
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 17th Dec 2011 20:53
You don't necessarily need to use memblocks. This is how I would do this.



I've used DATA statements to place the tiles, you could obviously use an external data file or choose the tiles at random.

Is there a reason you wanted to use memblocks?
MummyKillerSLO
17
Years of Service
User Offline
Joined: 5th Jul 2009
Location: Object Position Y(ObjChair)
Posted: 17th Dec 2011 21:52 Edited at: 17th Dec 2011 21:53
I appreciate your help, but as I say I must make image without drawing it to the screen and using get image command.

The idea is to make few memblocks from images (tiles) (Note: tiles are not the same image) and one memblock which will hold big image. So how can I copy memblock data from tiles memblocks and putting data into big memblock to make new image from this big memblock?

Excuse my english...

Happy to having and using DarkBASIC Professional...
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Dec 2011 22:04
29 games has the right idea, so let's modify his example to not draw on the screen.



I'm working on a memblock example if that's really what you want. I'll post here when it's finished.

TheComet

BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Dec 2011 23:00
To refine the example, you should SET BITMAP FORMAT 21 before making the bitmap. This allows transparent backgrounds.

29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 18th Dec 2011 01:13
Oops, didn't read your original post properly.

The Comet's post had a few errors in the code:

make bitmap

should be:

create bitmap

and then you need to use a SET CURRENT BITMAP command after it otherwise everything still gets drawn to the screen.

There was quite a good post regarding memblocks, detailing the bitmap / image memblock structure:

http://forum.thegamecreators.com/?m=forum_view&t=172867&b=1

A slight modification to the code I posted creates a bitmap from the stitched together images and then turn this bitmap into a memblock but it still uses the paste image command:



I've been looking at doing this with memblocks only but it's getting late and I really need to get some sleep. If I can figure it out I'll post. But, hopefully, TheComet will beat me to it and I can have a nice restful sunday
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Dec 2011 02:21
Whoops, thanks for fixing that

Quote: "and then you need to use a SET CURRENT BITMAP command after it otherwise everything still gets drawn to the screen."


That's not necessary, the command create bitmap already calls the command set current bitmap so the created one is the one selected.

TheComet

MummyKillerSLO
17
Years of Service
User Offline
Joined: 5th Jul 2009
Location: Object Position Y(ObjChair)
Posted: 18th Dec 2011 14:52
Well I've made my idea, but it somehow don't work as I wish. Any idea how to fix it?



Happy to having and using DarkBASIC Professional...
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 20th Dec 2011 02:02 Edited at: 20th Dec 2011 02:08
I ran your code, the first problem is in your function. The result of the if statement both copy data from memblock 2 to memblock 3, so you're not using memblock 1, i.e. image 1

However, that is minor compared to the next bit. Hope you're sitting comfortably.

The problem is that you're adding the memblock data together incorrectly.

I'll simplify the problem by using some 2x2 pixels images for the tiles.

Edit: I've put it in a code snippet to try and keep the formatting correct.




To demostrate this I've taken your code, only used one tile which is a blue square with a green border. I've set the variables: width = 1 and height = 1.



What you will see is the blue box with a green border as I described.

If you then press then down arrow keys, you'll see a column of tiles. All well and good. However, when you press the left arrow key, the image sort of goes nuts and you see blue boxes or rectangles, sometimes on the diagonal and so on.

Re-edit the code and change width to 2. Now when you run the code you should see a 20x10 image. The first row of this image is a line of green pixels that turns into a line of blue pixels then ends in a green pixel. That blue section is the second row of the tile (which will actually be a green pixel, a line of blue pixels and then a green pixel). Which is exactly what happened to the 2x2 tile image.

I hope that makes sense.

Login to post a reply

Server time is: 2026-07-09 17:43:13
Your offset time is: 2026-07-09 17:43:13