Skip to content

fixed imgData size in textures_svg_loading.c #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions textures_svg_loading/textures_svg_loading.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ static Image LoadImageSVG(const char *fileName, int width, int height)
(fileData[3] == 'g'))
{
struct NSVGimage *svgImage = nsvgParse(fileData, "px", 96.0f);
unsigned char *imgData = RL_MALLOC(svgImage->width*svgImage->height*4);

// NOTE: If required width or height is 0, using default SVG internal value
if (width == 0) width = svgImage->width;
if (height == 0) height = svgImage->height;

unsigned char *imgData = RL_MALLOC(width*height*4);

// Calculate scales for both the width and the height
float scaleWidth = width/svgImage->width;
Expand Down Expand Up @@ -150,4 +151,4 @@ static Image LoadImageSVG(const char *fileName, int width, int height)
}

return image;
}
}