VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 123456789[10] ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 06:57:01 03/27/00 Mon
Author: Michel
Subject: "Washed out" colors with palette images


This is a problem with the TResizeTransform.ApplyOnDest method, which caused a "washed out" look when resizing palettized images on NT with the HALFTONE stretch mode.

Here's the corrected implementation (sorry about the indentation, the forum does not maintain it):

procedure TResizeTransform.ApplyOnDest(
const Source : TDibGraphic;
const Dest : TDibGraphic );
var
pPoint : Windows.PPoint;
Radius : Single;
Filter : TInterpolationFilterFunc;
NewFormat : TImageFormat;
NewPalettePtr : PMaxLogPalette;

begin
FLastPercent := -1;
FLastPercent := DoProgress(Self, FOnProgress, 0, 0, 100, FLastPercent);

if FOverrideDestFormat then
NewFormat := FDestFormat
else
NewFormat := Source.ImageFormat;

{ only re-use the source palette on 16 and 256 colors destinations }

{ MB Nov 28, 1999. When destination format is is 16 or 256 colors, set
NewPalettePtr to nil, to use a default palette }
if NewFormat = Source.ImageFormat then
NewPalettePtr := Source.PalettePtr
else
NewPalettePtr := nil;

Dest.NewImage( FWidth, FHeight, NewFormat, NewPalettePtr,
Source.XDotsPerInch, Source.YDotsPerInch);

if FInterpolated then
begin
Filter := CFilters[FFilter].Filter;
Radius := CFilters[FFilter].Radius;

Interpolate(Source, Dest, Filter, Radius, Self);

DoProgress(Self, FOnProgress, 100, 0, 100, FLastPercent);
end
else
begin
FLastPercent := DoProgress(Self, FOnProgress, 50, 0, 100, FLastPercent);

{ using HALFTONE stretch mode, the stretch quality is much better.
The API help on SetStretchBltMode specifies that SetBrushOrgEx
must be called afterwords.

MB Dec 27, 1999. If the graphic is very small (for example, icon
size of less), it is preferable to resize without half toning.

MB Feb 23, 2000. Under NT, using the Windows.HALFTONE stretch mode
with palettized images caused a "wash out" effect
}
if ((Source.Width * Source.Height)
(Source.ImageFormat
ifTrueColor) then
SetStretchBltMode( Dest.DC, Windows.COLORONCOLOR )
else
SetStretchBltMode( Dest.DC, Windows.HALFTONE );

pPoint := nil;

SetBrushOrgEx( Dest.DC, 0, 0, pPoint );

StretchDiBits( Dest.DC, 0, 0, FWidth, FHeight,
0, 0, Source.Width, Source.Height,
Source.Bits, Windows.PBitmapInfo(@Source.BitmapInfo)^,
DIB_RGB_COLORS, SRCCOPY);

FLastPercent := DoProgress(Self, FOnProgress, 100, 0, 100, FLastPercent);
end;
end;

Registered users should replace the current implementation with this one.

For users evaluating the library, a new class derived from TResizeTransform overriding the ApplyOnDest method can be used to test the change.

Best regards,

Michel

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]


Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.