Results 1 to 6 of 6

Thread: [DELPHI] - TImage Effects

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    [DELPHI] - TImage Effects

    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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [DELPHI] - TImage Effects

    Moved to Other Programming Languages.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: [DELPHI] - TImage Effects

    Thanks, any logical answers anyone?

  4. #4

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: [DELPHI] - TImage Effects

    I was right in saying you never get a response back, decided to find an external VCL library instead

  5. #5
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: [DELPHI] - TImage Effects

    Quote Originally Posted by RobDog888
    Moved to Other Programming Languages.
    Quote Originally Posted by Madboy
    Thanks, any logical answers anyone?
    it is logical, Image.FromFile() in .NET, all formats

  6. #6

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: [DELPHI] - TImage Effects

    and that was a useful reply because...?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width