| 83 | } |
| 84 | |
| 85 | void 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 | |
| 106 | void OnOpen(Lemon::GUI::Button* btn){ |
| 107 | LoadImage(Lemon::GUI::FileDialog("/")); |
no test coverage detected