Bitmap / Image List Question.

I have icon(s) that i have added to an imagelist and i then store the images in a stream, then later use them from multiple places, it all works nicely.

now when i retrieve the image from the stream, its a bmp and large and icon-ny, i only load the one image i require into a bitmap, and then add it to a image list i have. its big and still icon-ny, now i want to shrink it and add it to another image list so i have a small image of the same graphic.

How do i tell a bmp to shrink by 50% ?

Thanks in advance
Kristian
LVL 1
KristianAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
andrewjbConnect With a Mentor Commented:
Form with two TImage components

Image1 has a bitmap loaded into it.

Image 2 is blank.

Do the following on a button press

Image2 set to be half the size of image 1


procedure TForm1.Button1Click(Sender: TObject);
var
  lHalfSize   : tBitmap;
  lRect   : tRect;
  lSource : tBitmap;
begin

  lSource := Image1.Picture.Bitmap;

  lHalfSize := tBitmap.Create;
  lHalfSize.Width := lSource.Width div 2;
  lHalfSize.Height := lSource.Height div 2;
  lRect := Rect( 0 , 0 , lSource.Width div 2 , lSource.Height div 2 );
  lHalfSize.Canvas.StretchDraw( lRect , lSource );

  Image2.Picture.Assign( lHalfSize );
end;

0
 
KristianAuthor Commented:
ive just logged on to delete this question ( as ive done it ), and i noticed theres a comment from andrew. i didnt get any notification at all about it.

i ended up doing :

Bitmap2 := TBitmap.Create;
Bitmap2.Width:=16;
Bitmap2.Height:=16;
Bitmap2.Palette:=Bitmap.Palette;
SetStretchBltMode(Bitmap2.Canvas.Handle,STRETCH_DELETESCANS);
Bitmap2.Canvas.Copyrect(Rect(0,0,16,16),Bitmap.Canvas,Rect(0,0,32,32));
Bitmap2.Palette:=Bitmap.Palette;

imagelist.AddMasked(Bitmap2,TempIRec.TransparentColor);

Bitmap2.free;

0
 
KristianAuthor Commented:
I will award you 25 points though for trying, which is appreciated.
but im a bit miffed that i didnt get a notification.
Cheers anyway
Kristian
0
 
KristianAuthor Commented:
i just got your notification ( 3 days late ) !!!!!!
Kristian
0
All Courses

From novice to tech pro — start learning today.