/*
lrgb: input 24bits rgb buffer
srgb: output 24bits rgb buffer
width: input width
height: input height
xscale: changed vector
yscale: changed vector
*/
int lrgbtosrgb(unsigned char *lrgb, unsigned char *srgb, int width, int height, float xscale, float yscale)
{
int in = 0, out = 0;
int ox, oy; //the pixel site is after changed
int rx, ry; //the pixel site is before changed
int temp = 0; //turn site(x,y) to memory storage
int outwidth = width * xscale; //after changed width
int outheight = height * yscale; //after changed height
//rx = ox/xscale + 0.5; // out--to--input
//ry = oy/yscale + 0.5; // out--to--input
for(oy = 0; oy < outheight; oy++)
{
ry = (int)(oy/0.5 + 0.5);
if(ry >= height)
ry--;
temp = ry * width *3; //origion pixel site of which width
for(ox = 0; ox < outwidth; ox++)
{
rx = (int)(ox/0.5 + 0.5);
if(rx >= width)
rx--;
in = temp + rx * 3; //change site(x,y) to storage
srgb[out+0] = lrgb[in+0];
srgb[out+1] = lrgb[in+1];
srgb[out+2] = lrgb[in+2];
out += 3;
}
}
return 0;
}