Skip to content

Ability to save parts of the canvas to a bitmap image #5

@Apostolique

Description

@Apostolique

Can be done with built-in MonoGame functions.

Render the canvas to a render target then call SaveToPng. For example:

DateTime now = DateTime.Now;
int year = now.Year;
int month = now.Month;
int day = now.Day;
string name = $"{year}-{month}-{day}";
string imageName = $"{name}.png";
using Stream file = File.OpenWrite(GetPath(imageName));
_r.SaveAsPng(file, _width, _height);

Was done in MotivationTracker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions