• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

How to convert and resize Graphics imaes?

How do I convert and resize emf or jpg to another format? Say convert emf to bitmp?

Example would be much appreciated.
0
Khaki
Asked:
Khaki
  • 2
1 Solution
 
mocartsCommented:
 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
 
KhakiAuthor Commented:
Thanks for the info.

If you can post the fix that be great.
0
 
mocartsCommented:
I have placed source for Rescaler.pas and Gifimage.pas at http://www.grava.lv/files/pro/rescaler.zip

wbr, mo.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now