Skip to content
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

Include height check parameter while scaling #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions src/fbgraphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1601,10 +1601,19 @@ void fbg_imageEx(struct _fbg *fbg, struct _fbg_img *img, int x, int y, float sx,
int h2 = (float)(ch + cy) * sy;
int i, j;

int d = w2 - cx2;
int dw = w2 - cx2;
int dh = h2 - cy2;

if (d >= (fbg->width - x)) {
w2 -= (d - (fbg->width - x));
if (dw >= (fbg->width - x)) {
w2 -= (dw - (fbg->width - x));
printf("Warning: Resulting width is greater than framebuffer width. \
Image will be compromised\n");
}

if (dh >= (fbg->height - y)) {
h2 -= (dh - (fbg->height - y));
printf("Warning: Resulting height is greater than framebuffer height. \
Image will be compromised\n");
}

unsigned char *pix_pointer = (unsigned char *)(fbg->back_buffer + (y * fbg->line_length + x * fbg->components));
Expand Down