MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SaveImage

Function SaveImage

Applications/LemonPaint/main.cpp:85–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85void SaveImage(char* path){
86 if(!path){
87 Lemon::GUI::DisplayMessageBox("LemonPaint", "Could not save: Invalid Filepath");
88 return;
89 }
90
91 char* ext = strrchr(path, '.');
92 if(!ext || strcmp(ext, ".png")){
93 Lemon::GUI::DisplayMessageBox("LemonPaint", "Could not save: Can only save images in PNG format!");
94 return;
95 }
96
97 FILE* image = fopen(path, "wb");
98 if(!image){
99 Lemon::GUI::DisplayMessageBox("LemonPaint", "Failed to open file for writing!");
100 return;
101 }
102
103 Lemon::Graphics::SavePNGImage(image, &canvas->surface, true);
104}
105
106void OnOpen(Lemon::GUI::Button* btn){
107 LoadImage(Lemon::GUI::FileDialog("/"));

Callers 1

OnSaveFunction · 0.85

Calls 4

DisplayMessageBoxFunction · 0.85
strrchrFunction · 0.85
strcmpFunction · 0.85
SavePNGImageFunction · 0.85

Tested by

no test coverage detected