?
Solved

How to convert and resize Graphics imaes?

Posted on 2003-03-03
3
Medium Priority
?
183 Views
Last Modified: 2010-04-04
How do I convert and resize emf or jpg to another format? Say convert emf to bitmp?

Example would be much appreciated.
0
Comment
Question by:Khaki
[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
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
mocarts earned 120 total points
ID: 8057480
 TForm1 = class(TForm)
  ...
    Image1: TImage;
  private
  ...
  end;

uses jpeg;

procedure TForm1.btnLoadClick(Sender: TObject);
begin
  image1.Picture.LoadFromFile('c:\my.jpg');
end;

procedure TForm1.btnSaveClick(Sender: TObject);
begin
  Image1.Picture.Bitmap.SaveToFile('c:\My.bmp');
end;

procedure TForm1.btnHalfClick(Sender: TObject);
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create;
  try
    bmp.PixelFormat := pf32bit;
    bmp.Width := Image1.Picture.Width div 2;
    bmp.Height := Image1.Picture.Height div 2;
    bmp.Canvas.StretchDraw(Rect(0, 0, bmp.Width, bmp.Height), Image1.Picture.Graphic);
    Image1.Picture.Assign(bmp);
  finally
    bmp.free;
  end;
end;

if you want better quality you can use some resample routine. you can found one at http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=12454
but there is bug with transparency - this routine doesn't take care about it. I have fixed this issue but I can give you link to source later (lets say tomorrow), if you need (and TGifimage, which integrates in Delphi's TImage,  too ;)
wbr, mo.
0
 

Author Comment

by:Khaki
ID: 8071385
Thanks for the info.

If you can post the fix that be great.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8083733
I have placed source for Rescaler.pas and Gifimage.pas at http://www.grava.lv/files/pro/rescaler.zip

wbr, mo.
0

Featured Post

Industry Leaders: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 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