[DUG] Resizing images

Kyley Harris Kyley at harrissoftware.com
Tue Jan 19 10:57:34 NZDT 2010


begin
  FSourceBMP.Assign(Value);
  if Zoom <> 1 then
  begin
    FBMP.Assign(FSourceBMP);
    FBMP.Width := Trunc(FSourceBMP.Width * Zoom);
    FBMP.Height := Trunc(FSourceBMP.Height * Zoom);
    Stretch(FBMP.Width, FBMP.Height ,sfBox,1,FSourceBMP,FBMP);
  end else
  FBMP.Assign(FSourceBMP);
  FImageAssigned := True;
end;

here is a snippet using a Zoom variable to stretch with Aspect ratio. Its
basically the same as TCanvas.stretch, but faster and far higher quality.
There are a few options (sfBox, Triangle) etc for how it samples the
pixels.. different ones get better results for Text, photo.. etc..

On Tue, Jan 19, 2010 at 10:53 AM, Kyley Harris <Kyley at harrissoftware.com>wrote:

> Sure.. gimme 5 minutes
> i can email you the source too.. its open
>
> On Tue, Jan 19, 2010 at 10:31 AM, Conor Boyd <Conor.Boyd at trimble.co.nz>wrote:
>
>>  Can you post your example?  Or another example?
>>
>> C.
>>
>>  ------------------------------
>> *From:* delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
>> *On Behalf Of *John Bird
>> *Sent:* Tuesday, 19 January 2010 9:46 a.m.
>> *To:* NZ Borland Developers Group - Delphi List
>> *Subject:* [DUG] Resizing images
>>
>>  Resizing images for Images, bitButtons and icons - I guess we all do
>> this.
>>
>> I have used IrfanView and Photofiltre for resizing images, and
>> noticed they tend to alter the edge pixels around an image - I guess it
>> averages the pixel colours on a sharp edge if resizing smaller. This is a
>> problem with images with a background surround - these pixels are not the
>> transparent background colour any more and create a ragged edge noticeable
>> when the image is on a darker background.
>>
>> How do others resize images properly?
>>
>>
>>
>> (Example is the Analogue clock with the image background some are using-
>> over a dark background you may see there are a fewer light pixels around the
>> edge that shouldn't be there)
>>
>>
>> John
>>
>> _______________________________________________
>> NZ Borland Developers Group - Delphi mailing list
>> Post: delphi at delphi.org.nz
>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>> Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
>> unsubscribe
>>
>
>
>
> --
> Kyley Harris
> Harris Software
> +64-21-671-821
>



-- 
Kyley Harris
Harris Software
+64-21-671-821
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20100119/f6be0249/attachment-0001.html 


More information about the Delphi mailing list