Add more error checking
This commit is contained in:
parent
db8418159e
commit
350c0bef08
1 changed files with 8 additions and 5 deletions
|
|
@ -209,12 +209,15 @@ void InputManager::get_clipboard_image_data_SDL(const std::function<void(std::st
|
||||||
if(cSurf) {
|
if(cSurf) {
|
||||||
SDL_LockSurface(cSurf);
|
SDL_LockSurface(cSurf);
|
||||||
SkDynamicMemoryWStream out;
|
SkDynamicMemoryWStream out;
|
||||||
SkPngEncoder::Encode(&out, SkPixmap(SkImageInfo::Make(cSurf->w, cSurf->h, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType), cSurf->pixels, cSurf->pitch), {});
|
if(SkPngEncoder::Encode(&out, SkPixmap(SkImageInfo::Make(cSurf->w, cSurf->h, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType), cSurf->pixels, cSurf->pitch), {})) {
|
||||||
out.flush();
|
out.flush();
|
||||||
SDL_UnlockSurface(cSurf);
|
SDL_UnlockSurface(cSurf);
|
||||||
SDL_DestroySurface(cSurf);
|
SDL_DestroySurface(cSurf);
|
||||||
result = out.detachAsVector();
|
result = out.detachAsVector();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error("Could not encode image data to PNG");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Bitmap could not be converted to new format");
|
throw std::runtime_error("Bitmap could not be converted to new format");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue