From: B.S on
first helo all, i am writing program for picture resizing but
something is wrong i coudn't anderstud
her is my code:




bool ResizeBmp(HBITMAP &bmp,int x1,int y1)
{
int x,y,rx,ry;
int i=0,j=0,l=0,t=0;
BITMAP bi;
int bit=4;

if(!GetObject(bmp, sizeof( BITMAP ), &bi)) {return false;}

x=bi.bmWidth;
y=bi.bmHeight;

BYTE *original = new BYTE[x * y * bit ];
BYTE *resize = new BYTE[x1 * y1 * bit ];

GetBitmapBits( bmp, x*y*bit, original );


if(x<x1) { rx=x1/(x1-x); }
if(x>x1) { rx=x/(x-x1); }

if(y<y1) { ry=y1/(y1-y); }
if(y>y1) { ry=y/(y-y1); }


while(1)
{

if(x<x1)
{
for(i=0; i<x1; i++)
{
if(i%rx!=0)
{
resize[l]=original[t];
l++; t++;
resize[l]=original[t];
l++; t++;
resize[l]=original[t];
l++; t++;
}
if(i%rx==0)
{
if(l>=x1*y1*bit){break;}
l=l+bit;
}
}
}

if(x>x1)
{
for(i=0; i<x; i++)
{
if(i%rx!=0)
{
resize[l]=original[t];
l++; t++;
resize[l]=original[t];
l++; t++;
resize[l]=original[t];
l++; t++;
}
if(i%rx==0){t=t+bit;}
}
}

if(y<y1) {if(j%ry==0) {l=l+(x1*bit);}}
if(y>y1) {if(j%ry==0) {t=t+(x *bit);}}

j++;
if(j>y1){break;}
}

for(j=0; j<y1; j++)
{
if(j%ry==0){FillY(resize,x1,y1,bit,j);}
}

for(j=0; j<x1; j++)
{
if(j%rx==0){FillX(resize,x1,y1,bit,j);}
}


bmp=(HBITMAP)CopyImage(bmp,IMAGE_BITMAP,x1,y1,LR_LOADFROMFILE);
SetBitmapBits(bmp,x1*y1*bit,resize);

delete[] original;
delete[] resize;

return true;
}



bool FillY(BYTE *byte,int x,int y,int bit,int y1)
{
int i=0,j=0,l=0,end;

i=(y1-1)*bit*x;
j=y1*bit*x;
l=(y1+1)*bit*x;

end=i+(x*bit);

if(y1!=y)
{
while(i<end)
{
byte[j]=(byte[i]+byte[l])/2;
i++; l++; j++;
}
}


if(y1==y)
{
while(i<end)
{
byte[j]=byte[i];
j++; i++;
}
}

return true;
}


bool FillX(BYTE *byte,int x,int y,int bit,int x1)
{
int i=0,j=0,l=0,end=0;

i=(x1-1)*bit;
j=x1*bit;
l=(x1+1)*bit;

if(x1>x)
{
for(end=0; end<y; end++)
{
for(int t=0;t<bit; t++){byte[j+t]=(byte[i+t]+byte[l+t])/2;}

i=i+bit*x;
j=j+bit*x;
l=l+bit*x;
}
}

if(x1==x)
{
for(end=0; end<y; end++)
{
for(int t=0;t<bit; t++){byte[j+t]=byte[i+t];}

i=i+bit*x;
j=j+bit*x;
}
}

return true;


sory for my bad english
From: Christian ASTOR on
On 7 fév, 20:59, "B.S" <giobs...(a)gmail.com> wrote:
> first helo all, i am writing program for picture resizing but
> something is wrong i coudn't anderstud
> her is my code:

You don't need all this code to resize a bitmap.

Just use StretchBlt() or StretchDIBits() or CopyImage() or
IShellImageData or GDI+, etc...
From: B.S on
> You don't need all this code to resize a bitmap.
>
> Just use StretchBlt() or StretchDIBits() or CopyImage() or
> IShellImageData or GDI+, etc...


i didn't liked that resized pictures so i desided to write my oun,
iallrady found mistak, it was in pixel bits