How would I go about saving a BMP screen shot during my game?
How would I go about saving a BMP screen shot during my game?
Aspyhyre eXtreme has component named TAsphyreScreener which you can use to take screenshots of your game. It alows saving screenshots in JPG format.
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.
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.
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).
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.
Last edited by SilverWarior; 14-06-2013 at 09:29 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.
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!
I have been using TAsphyreScreener to take a screenshot but occasionally it just grabs a blank (black) screen. Anybody else had this problem?
Bookmarks