PDA

View Full Version : Saving a screenshot in Asphyre Extreme?



Damot
14-06-2013, 12:19 PM
How would I go about saving a BMP screen shot during my game?

SilverWarior
14-06-2013, 01:25 PM
Aspyhyre eXtreme has component named TAsphyreScreener which you can use to take screenshots of your game. It alows saving screenshots in JPG format.

Darkhog
14-06-2013, 03:26 PM
Doesn't Asphyre render to object's TCanvas? If that's so, you could make invisible TImage, copy content of render target object into TImage's canvas (after setting proper dimensions of TImage.Picture.Bitmap), then use Image.picture.savetofile? That won't constrict you to jpeg (which is TERRIBLE format for screenshots), but will allow to save to any format Delphi/Lazarus (dunno which one you're using) supports, which includes PNG.

SilverWarior
14-06-2013, 04:51 PM
Asphyre uses TAsphyreCanvas and not regular pascal TCanvas.
I think that TAsphyreCanvas is named like so only becouse it also supports several similar drawing fuctions (DrawLine, DrawEclipse, DrawPicture instead of DrawGrapgic, etc.) like normal canvas does but it doesn't support direct saving of its contents into files.

Darkhog
14-06-2013, 08:07 PM
But can't content of TAsphyreCanvas be copied to regular canvas?

Even if you'd do this pixel-by-pixel (getting pixel's x/y and putting this pixel into normal canvas at proper positions) it shouldn't take long. Unless there is some blitting function to copy from AsphyreCanvas into regular one and vice versa - then it is even faster.

Anyway, JPG is terrible for screenshots as I said earlier and I strongly recommend trying other means to save it at least to bmp (you can then open this bmp with invisible TImage, save as png and remove bmp file to save space).

SilverWarior
14-06-2013, 09:07 PM
But can't content of TAsphyreCanvas be copied to regular canvas?

Not easily. You see content of TAsphyreCanvas is a TDXTexture which is saved in graphical memory itself. Now if you would be exporting this content your would first need to chage its type as the Textures saved in graphical memory are not in same format as ordinary TCanvas or TBitmap uses.

Anywhay if you are so against JPG images I'm sure it would be much easier to change the mentioned component itself so it would be able to store the image in different format. I'm sure JPG was used as both Delphi and FPC come out with JPEG file format support so you don't need any third party units or components for it to work.

EDIT: Just checked the source code of TScreener component and it could be easily modified to also save screenshots in other formats including (BMP, TGA, JPEG, PNG).
Now I'm not sure that all of theese formats are enabled by default or need some atitional external libraries but it is doable with only a slight change in components code.

Darkhog
17-06-2013, 07:16 PM
I'm not against JPEG by itself, but lossy compression in general - it might be good for photos, but for screenshots it is terrible.

SilverWarior
17-06-2013, 07:38 PM
I'm not against JPEG by itself, but lossy compression in general - it might be good for photos, but for screenshots it is terrible.

That laregly depends on compression level and the picture itself.

Damot
18-06-2013, 10:29 AM
Thanks for the replies.

I hadn't even seen TAsphyreScreener ! Just what I needed. It actually seems to automatically save in .JPG or .BMP depending on the file extension you specify as the filename. Brilliant stuff!

Theodore
10-01-2015, 05:05 PM
I have been using TAsphyreScreener to take a screenshot but occasionally it just grabs a blank (black) screen. Anybody else had this problem?

SilverWarior
11-01-2015, 03:55 AM
I have been using TAsphyreScreener to take a screenshot but occasionally it just grabs a blank (black) screen. Anybody else had this problem?

Is it realy black or is it of the same color that is used to clear the screen? (try changing the clear screen color to see if it afets the color of blank screenshot=.

If changing of clear color does afects your screenshot then you are taking it at wrong time (probably just after the screen was cleared and before next rendering phase).
So in such case I suggest that change your code in a way that pressing screenshot button does not executes the screenshot command right away but insted sets some bolean variable to true.
This variable should be checked befeore every new rendering cycle happens and if it is true the screenshot is taken before the next rendering phase if not well they you simply continue to the next rendering phase.

This will gurarante you that the screenshot will always be taken when the game sceen is fully rendered so there will be no visual artifacts present.

Theodore
12-01-2015, 10:30 AM
Thanks for your reply.

Yes it is actually a black screen shot, but the color I use to clear the screen is yellow. Although I think you do have a point, I shall have another look at the code and get back. Thanks.