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.

Newcomers DBPro Corner / Copy part of a bitmap/image/sprite to a file

Years of Service
User Offline
Joined: 27th Dec 2016
Posted: 10th Nov 2022 14:37
I am running Dark Basic Professional Version 1.071 under Windows 7, 64 bit.

I need a method to:
(1) Load a 'picture' of size 8872 x 6472 pixels,
(2) Extract a sub-picture from it using specified coordinates x1,y1 (upper left hand corner) and x2,y2 (lower right hand corner),
(3) Save the resulting sub-picture to a file.

I use the word 'picture' to mean bitmap, image, sprite, or combinations thereof - whatever will accomplish my goal.

I plan to use this method in a loop to generate a series of sub-pictures. I do not need to display anything on the screen, as I am only interested in the resulting files.

Any help or advice would be greatly appreciated. Thank you all.
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Nov 2022 15:47
Here is how I would do it.
1. Load the 'picture' file in using LOAD BITMAP.
2. Use GET IMAGE command to grab the particular sub-picture area you want.
3. Use MAKE MEMBLOCK FROM IMAGE to convert it to a memblock.
4. Write the memblock to a file using WRITE MEMBLOCK.

So many games to little time.

Login to post a reply

Server time is: 2024-02-26 13:27:26
Your offset time is: 2024-02-26 13:27:26