SavePixmapPNG problem

BlitzMax Forums/BlitzMax Programming/SavePixmapPNG problem

drnmr(Posted 2005) [#1]
is this the command to use for saving an image the user of a program created? if yes, could anyone please tell me how to use it because the command description wasn't exactly helpful.


tonyg(Posted 2005) [#2]
Graphics 800,600
image:timage = LoadImage("my_image.png")
start_time=MilliSecs()
DrawImage image,0,0
my_pixmap:tpixmap=GrabPixmap(0,0,800,600)
Flip
SavePixmapPNG(my_pixmap,"pixmap_image.png")
end_time=MilliSecs()
DrawText end_time-start_time,0,0
Flip
WaitKey()




drnmr(Posted 2005) [#3]
what exactly does this do to the image you loaded, if anything?


FlameDuck(Posted 2005) [#4]
what exactly does this do to the image you loaded, if anything?
Draws it to the screen.


tonyg(Posted 2005) [#5]
It doesn't do anything to the image... should it?
You might want to change the grabpixmap to use the same x,y as the drawimage (i.e. grab the image rather than the whole screen) and use imagewidth/imageheight to get the extents.


drnmr(Posted 2005) [#6]
how do i save an image that i create in a program?


tonyg(Posted 2005) [#7]
Exactly the same way.
If you want to save the background screen use the grabpixmap method. If you have the image as a TImage use
mypixmap:TPixmap=lockimage(myimage)
SavePixmapPNG(my_pixmap,"pixmap_image.png")
unlockimage(image)



drnmr(Posted 2005) [#8]
thanks for helping me with saving images. do you know how i could save something as a user defined file name?


ImaginaryHuman(Posted 2005) [#9]
The filename is just a string variable. Have the user enter the string somehow, either with Input or with a program that reads keys, then save the png with that string as the filename.


drnmr(Posted 2005) [#10]
can you make a texbox with blitzmax?


drnmr(Posted 2005) [#11]
never mind that last question. i've been having problems getting input to recieve anything but numbers. is there a way to for input to recieve letters?


ImaginaryHuman(Posted 2005) [#12]
give it a string variable instead of an int


drnmr(Posted 2005) [#13]
how do i give it a string variable??


tonyg(Posted 2005) [#14]
Is there a hole in your bucket by any chance? :)
If you're using input then...
filename$=input("What is your filename?"
or
filename:string=input("What is your filename?")
specifying whether you want the variable to be local or global.


drnmr(Posted 2005) [#15]
when i tried this, it messed up my program.


tonyg(Posted 2005) [#16]
Provide your code and how it 'messed up'.


drnmr(Posted 2005) [#17]
it messed up by waiting for a response in the command module and graphics window at the same time, giving my program a not responding label.



ImaginaryHuman(Posted 2005) [#18]
Are you doubly checking for the enter key to be pressed. The input command finishes taking input when the user presses enter. You can assume that once the input has been made, the already pressed enter. You shouldn't need to additionally check for enter to be pressed - unless that's some features you built into your program.


tonyg(Posted 2005) [#19]
So, does this not give you a white rect png file?
filename$ = Input("Type in filename") 'Coding for recieving filename
Graphics 640,480
While Not KeyHit(key_escape)
	DrawRect 0,0,640,480
	If KeyHit(key_space) 'save image
        image:TPixmap=GrabPixmap(0,0,640,480)
        SavePixmapPNG(image,filename$+".png")
    EndIf 
    Flip
Wend

BTW You shouldn't really use input as it's not a graphical input command.
To pre-empt your next question...
Graphic input1
Graphic input2


drnmr(Posted 2005) [#20]
saving works fine... without input, that is


tonyg(Posted 2005) [#21]
Does the code I gave above work or not?
If not, what goes wrong?
If it works then post your whole code rather than the snippet you gave earlier.


drnmr(Posted 2005) [#22]
your code doesn't mess up the program, but it doesn't save for me.


BlitzSupport(Posted 2005) [#23]
EDIT: Thanks.


tonyg(Posted 2005) [#24]
your code doesn't mess up the program, but it doesn't save for me.


So,. the code I provided runs OK but doesn't produce a
file with the name entered by the user in the same directory that the program is saved?
That's very odd. What release of Bmax are you using?
Just to confirm...
1) File / New in BlitzMax
2) Copy and paste code.
3) Save program
4) Run program...
4a) Enter name e.g. TEST
4b) See the white rectangle displayed
4c) Press Spacebar
4d) Escape to end program
5) Check directory in which the program was saved for file TEST.png.
.
Are you saying the TEST.png file doesn't exist?


drnmr(Posted 2005) [#25]
i am using version 1.09.


tonyg(Posted 2005) [#26]
So... you're saying at 1.09 the scenario I listed above results in no TEST.png file being produced in the directory where your program is saved?
Why are you not using 1.10?
What happens at that level?