mirror of
https://github.com/hyprwm/hyprgraphics.git
synced 2025-12-25 03:00:03 +01:00
napkin story
This commit is contained in:
parent
ca0fb7b941
commit
846d85c3de
3 changed files with 1 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue