PDA

Click to See Complete Forum and Search --> : [DELPHI] - TImage Effects


Madboy
Aug 13th, 2005, 01:25 PM
Ok, ive just begun a new project the other day, and have been working out how to implement some effects features. Using some online sample code the below function can invert the colours of a bitmap in a TImage. Works fine too:

function InvertBitmap(MyBitmap: TBitmap): TBitmap;
var
x, y: Integer;
ByteArray: PByteArray;
begin
MyBitmap.PixelFormat := pf24Bit;
for y := 0 to MyBitmap.Height - 1 do
begin
ByteArray := MyBitmap.ScanLine[y];
for x := 0 to MyBitmap.Width * 3 - 1 do
begin
ByteArray[x] := 255 - ByteArray[x];
end;
end;
Result := MyBitmap;
end;

imgMain.Picture.Bitmap := InvertBitmap(imgMain.Picture.Bitmap);
imgMain.Refresh;

Problem: Im not using a TImage control but an external component which handles more filetypes, such as JPG. Because of this, the above function will only invert the image if its a bitmap, any other file type is converted to white.

Question: How can i invert ANY image type?

My idea was to convert the image, say JPG to BMP, invert it, then convert it back. But it seems a lot of hassle for just inverting an image.

Appreciate any help or solutions to such an easy problem :thumb:

RobDog888
Aug 15th, 2005, 12:41 PM
Moved to Other Programming Languages. ;)

Madboy
Aug 15th, 2005, 12:59 PM
Thanks, any logical answers anyone?

Madboy
Aug 22nd, 2005, 05:51 AM
I was right in saying you never get a response back, decided to find an external VCL library instead

Phill64
Aug 29th, 2005, 01:23 AM
Moved to Other Programming Languages. ;)

Thanks, any logical answers anyone?

it is logical, Image.FromFile() in .NET, all formats

Madboy
Aug 29th, 2005, 05:37 PM
and that was a useful reply because...?