Why dont you clip the bitmap bits directly?
int cxDest = cxImage/2;
int cyDest = cyImage/2;
int bpls = ((cxImage*sizeof(RGBTRIPLE))+3)&~3;
int bpld = ((cxDest *sizeof(RGBTRIPLE))+3)&~3;
unsigned char* lps = (unsigned char*)local_member_buffer_1 + (bpls*(cyImage-cyDest-1));
unsigned char* lpd = (unsigned char*)prgb + (bpld*(cyDest-1));
unsigned char* lpe = lps - (bpls*cyDest);
for(;lps>lpe;lps-=bpls,lpd-=bpld)
{
memcpy(lpd,lps,sizeof(RGBTRIPLE)*cxDest);
}
Regards.
[edit]
i suppose you want to create a stereo image with same image left and right:
int cxDest = cxSource/2;
int cyDest = cySource;
int bpls = ((cxSource*3)+3)&~3;
int bpld = ((cxDest *3)+3)&~3;
unsigned char* lps = local_member_buffer_1;
unsigned char* lpd = prgb;
unsigned char* lpe = local_member_buffer_1+ + (bpls*cySource);
for(;lps<lpe;lps+=bpls,lpd+=bpld)
{
memcpy(lpd,lps,sizeof(RGBTRIPLE)*cxSource);
memcpy(lpd+(sizeof(RGBTRIPLE)*cxSource),lps,sizeof(RGBTRIPLE)*cxSource);
}
Good luck.
Kozlov Sergey:
Yes. But it resizes only height.
I need also width.
[edit]
with shrink original pixel, this is a little bit larger:
int cxDest = cxSource;
int cyDest = cySource/2;
int bpls = ((cxSource*3)+3)&~3;
int bpld = ((cxDest *3)+3)&~3;
unsigned char* lps = local_member_buffer_1;
unsigned char* lpd = prgb;
unsigned char* lpe = local_member_buffer_1+ + (bpls*cySource);
unsigned char* lppd;
unsigned char* lppe;
unsigned char* lpps1;
unsigned char* lpps2;
typedef struct
{
static void shrink4x4(RGBTRIPLE* a,RGBTRIPLE* b,RGBTRIPLE* c,RGBTRIPLE* d,RGBTRIPLE* r)
{
r->rgbtRed = ((unsigned int)a->rgbtRed +
(unsigned int)b->rgbtRed +
(unsigned int)c->rgbtRed +
(unsigned int)d->rgbtRed)>>2;
r->rgbtGreen = ((unsigned int)a->rgbtGreen +
(unsigned int)b->rgbtGreen +
(unsigned int)c->rgbtGreen +
(unsigned int)d->rgbtGreen)>>2;
r->rgbtBlue = ((unsigned int)a->rgbtBlue +
(unsigned int)b->rgbtBlue +
(unsigned int)c->rgbtBlue +
(unsigned int)d->rgbtBlue)>>2;
}
}_;
for(;lps<lpe;lps+=bpls*2,lpd+=bpld)
{
lppe = lpd + sizeof(RGBTRIPLE)*(cxDest/2);
for(lppd=lpd,lpps1=lps,lpps2=lps+bpls;lppd<lppe;lppd+=sizeof(RGBTRIPLE))
{
_::shrink4x4
(
(RGBTRIPLE*)lpps1,
(RGBTRIPLE*)(lpps1+sizeof(RGBTRIPLE)),
(RGBTRIPLE*)lpps2,
(RGBTRIPLE*)(lpps2+sizeof(RGBTRIPLE)),
(RGBTRIPLE*)lppd
);
lpps1 += sizeof(RGBTRIPLE)+sizeof(RGBTRIPLE);
lpps2 += sizeof(RGBTRIPLE)+sizeof(RGBTRIPLE);
}
lppe = lpd + sizeof(RGBTRIPLE)*(cxDest);
for(lpps1=lps,lpps2=lps+bpls;lppd<lppe;lppd+=sizeof(RGBTRIPLE))
{
_::shrink4x4
(
(RGBTRIPLE*)lpps1,
(RGBTRIPLE*)(lpps1+sizeof(RGBTRIPLE)),
(RGBTRIPLE*)lpps2,
(RGBTRIPLE*)(lpps2+sizeof(RGBTRIPLE)),
(RGBTRIPLE*)lppd
);
lpps1 += sizeof(RGBTRIPLE)+sizeof(RGBTRIPLE);
lpps2 += sizeof(RGBTRIPLE)+sizeof(RGBTRIPLE);
}
}