Question: Hello I just need help simplifying this C code and making it run faster, please note where u make these changes, thank you.#include typedef struct
Hello I just need help simplifying this C code and making it run faster, please note where u make these changes, thank you.#include
typedef struct
uintt pixels;
unsigned int w;
unsigned int h;
imaget;
#define getBytevalue nvalue n & xFF
uintt getpixelimaget image unsigned int x unsigned int y
return imagepixelsyimagewx;
float maxfloat a float b return a b a : b; ;
float lerpfloat s float e float treturn sest;
float blerpfloat c float c float c float c float tx float ty
return lerplerpc c tx lerpc c tx ty;
void putpixelimaget image unsigned int x unsigned int y uintt color
imagepixelsyimagew x color;
void scaleimaget src imaget dst float scalex, float scaley
int newWidth intsrcwscalex;
int newHeightintsrchscaley;
int x y;
forx y; y newHeight; x
ifx newWidth
x ; y;
float gx x floatnewWidthsrcw ;
float gy y floatnewHeightsrch ;
Image should be clamped at the edges and not scaled.
float gx maxx floatnewWidthsrcwf srcw ;
float gy maxy floatnewHeightsrch srch ;
int gxi intgx;
int gyi intgy;
uintt result;
uintt c getpixelsrc gxi, gyi;
uintt c getpixelsrc gxi gyi;
uintt c getpixelsrc gxi, gyi;
uintt c getpixelsrc gxi gyi;
uintt i;
fori ; i ; i
uintt&resulti blerpuintt&ciuintt&ciuintt&ciuintt&ci gxi gx gyi gy; this is shady
result uinttblerpgetBytec i getBytec i getBytec i getBytec i gx gxi, gy gyii;
putpixeldstx y result;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
