Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Apostolique opened this issue Dec 12, 2021 · 0 comments
Open

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

Apostolique opened this issue Dec 12, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@Apostolique
Copy link
Owner

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.

@Apostolique Apostolique added the enhancement New feature or request label Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant