napkin story

This commit is contained in:
Honkazel 2025-02-04 12:35:50 +05:00
parent ca0fb7b941
commit 846d85c3de
3 changed files with 1 additions and 4 deletions

View file

@ -110,7 +110,6 @@ std::expected<cairo_surface_t*, std::string> BMP::createSurfaceFromBMP(const std
cairo_format_t format = CAIRO_FORMAT_ARGB32;
int stride = cairo_format_stride_for_width(format, bitmapHeader.width);
// Good cast!
unsigned char* imageData = (unsigned char*)malloc(static_cast<size_t>(bitmapHeader.height * stride));
if (bitmapHeader.numberOfBitPerPixel == 24)

View file

@ -31,7 +31,7 @@ std::expected<cairo_surface_t*, std::string> PNG::createSurfaceFromPNG(const std
spng_set_png_buffer(ctx, PNGCONTENT.data(), PNGCONTENT.size());
spng_ihdr ihdr{.width=0};
spng_ihdr ihdr{.width = 0};
if (int ret = spng_get_ihdr(ctx, &ihdr); ret)
return std::unexpected(std::string{"loading png: spng_get_ihdr failed: "} + spng_strerror(ret));
@ -56,7 +56,6 @@ std::expected<cairo_surface_t*, std::string> PNG::createSurfaceFromPNG(const std
if (!succeededDecode && ret == SPNG_EBUFSIZ) {
// hack, but I don't know why decoded_image_size is sometimes wrong
// Good cast! At least now it's explicit
imageLength = static_cast<size_t>(ihdr.height * ihdr.width * 4) /* FIXME: this is wrong if we doing >32bpp!!!! */;
imageData = (uint8_t*)realloc(imageData, imageLength);

View file

@ -47,7 +47,6 @@ std::expected<cairo_surface_t*, std::string> WEBP::createSurfaceFromWEBP(const s
config.options.no_fancy_upsampling = 1;
config.output.u.RGBA.rgba = CAIRODATA;
config.output.u.RGBA.stride = CAIROSTRIDE;
// Really good cast!
config.output.u.RGBA.size = static_cast<size_t>(CAIROSTRIDE * HEIGHT);
config.output.is_external_memory = 1;
config.output.width = WIDTH;