09
Aug
07

JPEG smooth resize with Graphics32

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,JPEG, StdCtrls,   ExtCtrls, GR32, GR32_Image, GR32_Transforms, GR32_Resamplers, GR32_System;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    function RescalePic(aFileName,destinationFile: String;x,y:integer): TBitmap;

  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
function TForm1.RescalePic(aFileName,destinationFile: String;x,y:integer): TBitmap;
Var
  R: TKernelResampler;
  ASrcImage: TBitMap32;
  ADstImage: TBitMap32;
  ABmp: TBitMap;
  AJPeg: TJPegImage;
  AScale: Extended;
  lPageIndex : Integer;
begin
  // Zum Abspeichern als Jpeg
  AJPeg     := TJPEGImage.Create;
  ABmp      := TBitMap.Create;
  // Original
  ASrcImage := TBitmap32.Create;
  // destintaion
  ADstImage := TBitMap32.Create;
  try
    ASrcImage.LoadFromFile(aFileName);
    ADstImage.Width  := x;
    ADstImage.Height := y;
    R := TKernelResampler.Create(ASrcImage);
    R.Kernel := TLanczosKernel.Create;

    ADstImage.Draw(ADstImage.BoundsRect, ASrcImage.BoundsRect, ASrcImage);
    ABmp.Assign(ADstImage);

    result := ABmp;
    AJPeg.Assign(ABmp);
    AJPeg.SaveToFile(destinationFile);

  finally
    AJPeg.Free;
    ADstImage.Free;
    ASrcImage.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
        RescalePic(’c:\swftools\xpage1.jpg’,’c:\swftools\xpage1.jpg2.jpg’,400,300);
end;

end.


0 Responses to “easyphp et url rewriting”


  1. No Comments

Leave a Reply