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 / Save .....Bitmap

Author
Message
tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 11th Nov 2002 17:29
Hi
If with "save bitmap" could save the whole screen (p.es 640,480)
like could I save one part of this in an only bitmap (p.es.:256,256)?

Se con "save bitmap" posso salvare l'intero screen ,
come posso salvare in un bitmap solo una parte di questo ?

Thanks
Skid
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United Kingdom
Posted: 11th Nov 2002 17:37
Without being at home i can't tell you how to do it, but i know its possable. One way you could do it is by saveing the big bitmap, then opening it again, using the get image command to get the section you want then save that image, i think that would work but i can't test it till i get home.

Skid
tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 13th Nov 2002 10:57
set display mode 800,600,16
sync on

do
cls
ink rgb(r,v,b),0


box 0,0,128,128


ink rgb(255,255,255),0
box 48,480,88,520
ink rgb(0,0,0),0
if mousex() > 48 and mousex() < 88
if mousey() > 480 and mousey() < 520
if mouseclick() = 1 and r < 246 and v < 246 and b < 246 then r = m_m(r+1,0,255) :v = m_m(v+1,0,255):b = m_m(b+1,0,255)
if mouseclick() = 2 and r < 256 and v < 256 and b < 256 then r = m_m(r-1,0,255) :v = m_m(v-1,0,255):b = m_m(b-1,0,255)
endif
endif
if inkey$()="z" then create bitmap 22,128,128 :save bitmap "prova22.bmp",22
sync
loop
rem FUNCTION
function click(x1,y1,x2,y2)
clicked=0
if mousex()>x1 and mousex()<x2
if mousey()>y1 and mousey()<y2
if mouseclick()=1
clicked=1
endif
endif
endif
endfunction click
function m_m(n,min,mas)
if n > mas then number = mas
if n < min then number = min
endfunction n

tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 13th Nov 2002 11:00
Mouseclick left+white mouseclick right +black
For save only 128x128 gray bitmap created ?

thanks

Skid
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United Kingdom
Posted: 14th Nov 2002 01:48
Ok what you did there was a good attempt, but this is a better way to do it in DB:

first put whatevery you want on the screen then
save bitmap "filename.bmp"
load bitmap "filename.bmp",1
get image 1,x1,y1,x2,y2
delete bitmap 1
save image "filename2.bmp",1

that works on my computer, you may be able to save over the first filename.bmp with the second one, you'll have to test it yourself

i ran this and it worked fine


Skid
tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 14th Nov 2002 12:57
Thank you Skid for the code, how come could I save progressive bmp ?

if inkey$()="z" then p=p+1:save bitmap "p.bmp":load bitmap "p.bmp",1:get image 1,0,0,128,128:delete bitmap 1:save bitmap "pics_"+str$(p)+".bmp":

,

Skid
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United Kingdom
Posted: 14th Nov 2002 16:42
Do that code work, because if you tell it to save the bitmap it shouldn't because the get image, sets it to a deffent set of commands, i think it may need to be save image for the second save.

As for the progressive bmp, there should be no problem doing it, you got the right idea as well. However if you rerun the code it will save over the first lot you made when you ran it the time befor.

There are two ways to over come this, you can get the program to look thought the bitmaps and see which was the last one created, or you can use the file commands and make a txt file that holds the number bmp created. how that made sense

Skid
tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 15th Nov 2002 10:02
Sorry Skid
an example please -

Thanks

Skid
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United Kingdom
Posted: 16th Nov 2002 23:09
ok then *makes one for the top of my head*


varible = 1
if file exist("filename.txt") = 0
open to write 1,"filename.txt"
write long 1,varible
close file 1
else
open to read "filename.txt",1
read long 1,varible
close file 1
endif
save bitmap "filename" + str$(varible) + ".bmp"
load bitmap "filename" + str$(varible) + ".bmp",1
get image 1,x1,y1,x2,y2
delete bitmap 1
delete file "filename" + str$(varible) + ".bmp"
save image "filename" + str$(varible) + ".bmp",1
varible = varible + 1
delete file "filename.txt"
open to write 1,"filename.txt"
write long 1,varible
close file 1

ok thats the code time to test it,



Skid
tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 25th Nov 2002 09:08
Thanks Skill -

tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 26th Nov 2002 12:23
Hi , Skill
sorry but why I write this don't work -

if mouseclick() = 1 then save bitmap "filename" + str$(varible) + ".bmp":load bitmap "filename" + str$(varible) + ".bmp",1:get image 1,100,100,128,128:delete bitmap 1:delete file "filename" + str$(varible) + ".bmp":save image "filename" + str$(varible) + ".bmp",1

or

if inkey$()="p" then save bitmap "filename" + str$(varible) + ".bmp":load bitmap "filename" + str$(varible) + ".bmp",1:get image 1,100,100,128,128:delete bitmap 1:delete file "filename" + str$(varible) + ".bmp":save image "filename" + str$(varible) + ".bmp",1


Many tanks

Skid
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United Kingdom
Posted: 26th Nov 2002 14:36
Try useing end if's they will make your code look better and may fix the problem, ie
if inkey()="p"
varible = 1
if file exist("filename.txt") = 0
open to write 1,"filename.txt"
write long 1,varible
close file 1
else
open to read "filename.txt",1
read long 1,varible
close file 1
endif
save bitmap "filename" + str$(varible) + ".bmp"
load bitmap "filename" + str$(varible) + ".bmp",1
get image 1,x1,y1,x2,y2
delete bitmap 1
delete file "filename" + str$(varible) + ".bmp"
save image "filename" + str$(varible) + ".bmp",1
varible = varible + 1
delete file "filename.txt"
open to write 1,"filename.txt"
write long 1,varible
close file 1
endif

Skid
tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 29th Nov 2002 14:39
Thanks Skill , prove it -

tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 29th Nov 2002 19:19
Hi Skill
compare this message :

open to read "filename.txt" ,1

Error :
Parameter mismatch.Open to read expects integer string -

Skid
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United Kingdom
Posted: 29th Nov 2002 23:59
The error is in the way you wrote the code, the error message tell you exsacly whats wrong with it.

Parameter mismatch.Open to read expects integer string
meens you should right it like this
open to read 1,"filename.txt"
and not with the one at the end
oh and its Skid

Skid
tmtm
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location:
Posted: 3rd Dec 2002 21:01
Thank you Skill -Is correct -


Login to post a reply

Server time is: 2024-04-19 13:28:35
Your offset time is: 2024-04-19 13:28:35