Jump to content

Search the Community

Showing results for tags 'transparency'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 1 result

  1. Hello! It is required to calculate the illumination of a point in a TPNGImage object, taking into account transparency. I wrote the following algorithm: function GetBrightness(const AImage: TPNGImage; AX, AY: Integer): Integer; var LColor, LTransparentColor: TColor; r, g, b, alpha: Byte; tr, tg, tb: Byte; LDstAlpha: pByteArray; begin LColor := AImage.Pixels[AX, AY]; r := Byte(LColor); g := Byte(LColor shr 8); b := Byte(LColor shr 16); if AImage.Transparent and (LColor <> 0) then begin if (AImage.Header.ColorType in [COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA]) then begin LDstAlpha := AImage.AlphaScanline[AY]; if Assigned(LDstAlpha) then begin alpha := LDstAlpha[AX]; r := Byte(Round(r * alpha/255)); g := Byte(Round(g * alpha/255)); b := Byte(Round(b * alpha/255)); end; end else if AImage.Header.ColorType = COLOR_PALETTE then begin LTransparentColor := AImage.TransparentColor; tr := Byte(LTransparentColor); tg := Byte(LTransparentColor shr 8); tb := Byte(LTransparentColor shr 16); r := Byte(Round(r * tr/255)); g := Byte(Round(g * tg/255)); b := Byte(Round(b * tb/255)); end; end; Result := Round(0.3*r + 0.59*g + 0.11*b); end; Please analyze my algorithm for errors. P.S. Unfortunately, in my test base there are no images with TransparentColor - only with alpha channel. Alexander.
×