Results 1 to 10 of 12

Thread: Saving a screenshot in Asphyre Extreme?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Saving a screenshot in Asphyre Extreme?

    How would I go about saving a BMP screen shot during my game?

  2. #2
    Aspyhyre eXtreme has component named TAsphyreScreener which you can use to take screenshots of your game. It alows saving screenshots in JPG format.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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).

  6. #6
    Quote Originally Posted by Darkhog View Post
    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.
    Last edited by SilverWarior; 14-06-2013 at 09:29 PM.

  7. #7
    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!

  8. #8
    I have been using TAsphyreScreener to take a screenshot but occasionally it just grabs a blank (black) screen. Anybody else had this problem?

  9. #9
    Quote Originally Posted by Theodore View Post
    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.

  10. #10
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •