SavePixmapPNG problem
BlitzMax Forums/BlitzMax Programming/SavePixmapPNG problem
| ||
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. |
| ||
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() |
| ||
what exactly does this do to the image you loaded, if anything? |
| ||
what exactly does this do to the image you loaded, if anything? Draws it to the screen. |
| ||
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. |
| ||
how do i save an image that i create in a program? |
| ||
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) |
| ||
thanks for helping me with saving images. do you know how i could save something as a user defined file name? |
| ||
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. |
| ||
can you make a texbox with blitzmax? |
| ||
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? |
| ||
give it a string variable instead of an int |
| ||
how do i give it a string variable?? |
| ||
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. |
| ||
when i tried this, it messed up my program. |
| ||
Provide your code and how it 'messed up'. |
| ||
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. |
| ||
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. |
| ||
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 |
| ||
saving works fine... without input, that is |
| ||
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. |
| ||
your code doesn't mess up the program, but it doesn't save for me. |
| ||
EDIT: Thanks. |
| ||
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? |
| ||
i am using version 1.09. |
| ||
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? |