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 / Saving an image from the screen

Author
Message
jerryd
11
Years of Service
User Offline
Joined: 20th Feb 2013
Location:
Posted: 3rd Apr 2013 06:37
DarkBasic forum,

I'm trying to save an image from bitmap 0(the screen) to an
external file using the save image command.

set current bitmap 0
get image 0 ,0, 0, 32, 32
save image "screen_image", 0

When I run the program I get an "Illegal image number on
the "get image" line. If I comment out that line I get the
same error message on the "save image" line.

What am I doing wrong here?

jerryd
Rain Man
17
Years of Service
User Offline
Joined: 19th Nov 2007
Location:
Posted: 3rd Apr 2013 09:16 Edited at: 3rd Apr 2013 09:16
Zero is an invalid image number. Change the image numbers to one (or more).

Ten minutes to Wapner.
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Apr 2013 12:34
Hi there.
Rain Man gave you the answer...and don't forget to add a flag to avoid stretching, filter, colorkey...

instead of:
get image 1 ,0, 0, 32, 32

could be like this:
get image 1 ,0, 0, 32, 32,1

Quote: "0-use stretching, filter, colorkey
1-no stretching, no filter, colorkey
2-use stretching, no filter, no colorkey (grab from alpha bitmap retain alpha channel)
3-no stretching, no filter, no colorkey (grab from alpha bitmap retain alpha channel)"


I'm not a grumpy grandpa
jerryd
11
Years of Service
User Offline
Joined: 20th Feb 2013
Location:
Posted: 4th Apr 2013 04:03
DarkBasic forum,

Thanks for the replies.

I changed the image number to 1 and the program compiles
and runs. I get a file stored in my folder but it's not
the kind of file I expected. What I'm trying to do is
put a sprite or bitmap on the screen at location 0,0 and
then save that screen location to a file that is a bitmap
or png.

jerryd
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Apr 2013 16:07
If you want to save the image with the sprite in it...try paste sprite first and then get image..

I'm not a grumpy grandpa
jerryd
11
Years of Service
User Offline
Joined: 20th Feb 2013
Location:
Posted: 6th Apr 2013 01:25
chafari,

I do have a sprite or rather a bitmap image on the screen that
is 32X32 and located at screen location 0,0 and I see the image
on the screen.

Here's the whole program:

sync on
sync rate 30

load bitmap "image.bmp", 1
copy bitmap 1,0

set current bitmap 0
save image "screen_image", 1, 0

do
sync
loop


How can I save a file of this image?

jerryd
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Apr 2013 02:30
Before saving an image , we have to get the image. We can load the bitmap, but we have to get ...for example:
get image 1,0,0,320,240,1

That means we capture the image 1 from 0,0 to 320*240, and the flag 1 "no stretching, no filter, colorkey"

So when we have the image, we can save the image like that:

save image "my_image.jpg",1

I'm not a grumpy grandpa
jerryd
11
Years of Service
User Offline
Joined: 20th Feb 2013
Location:
Posted: 6th Apr 2013 03:07
chafari,

Thanks, I got that to work.

jerryd
Valentinelee
11
Years of Service
User Offline
Joined: 25th Apr 2013
Location:
Posted: 25th Apr 2013 10:48
Here is a image saving parameter setting requirement article.what's more, you also can use a image saving program to deal with this problem, this way looks much easier for you only need to operate an easy software.

image processing

Login to post a reply

Server time is: 2024-11-27 07:11:45
Your offset time is: 2024-11-27 07:11:45