?
Solved

Bitmap / Image List Question.

Posted on 2003-02-20
4
Medium Priority
?
186 Views
Last Modified: 2013-11-19
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
0
Comment
Question by:Kristian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 12

Accepted Solution

by:
andrewjb earned 200 total points
ID: 7989310
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
 
LVL 1

Author Comment

by:Kristian
ID: 7993481
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
 
LVL 1

Author Comment

by:Kristian
ID: 7993489
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
 
LVL 1

Author Comment

by:Kristian
ID: 8007034
i just got your notification ( 3 days late ) !!!!!!
Kristian
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this second Micro Tutorial in the series,  viewers will learn more basic shortcuts and functions of Illustrator. In this tutorial you will learn about the eyedropper tool, zoom , ellipses and more.
Learn how to create interesting presentations by including videos to keep your audience engaged using Prezi. Select "Insert" from the top menu in your Prezi editor: Select "YouTube Video": Paste the video URL into the prompt: "Select "Insert":…
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question