Search the Community
Showing results for tags 'png'.
Found 2 results
-
Calculation of the illumination of a point for PNG image, taking into account transparency
lisichkin_alexander posted a topic in Algorithms, Data Structures and Class Design
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. -
Datamodule with ImageCollection of PNGs loading with packages
Mike Scott posted a topic in General Help
I have a datamodule with imagecollections holding .PNG files. If I compile a Debug build (no packages) all is well. However, a Release build with various packages including vcl;vclx;rtl;vclimg;vclSmp;vclwinX;bindengine; reliably gives trouble. I CoInitialize before and CoUninitialize after the load. The loading mechanism which gives an AV in vcl280.bpl. Image 1 shows what Eurekalog diagnoses. The images are all PNG files. Image 2 shows the source. I get an AV when creating the DatamoduleAlImages or when I get to Application.Run.- 2 replies
-
- datamodule
- imagecollection
-
(and 3 more)
Tagged with: