Changeset 521 for GraphicTest/Packages/bgrabitmap/bgracolorquantization.pas
- Timestamp:
- Apr 17, 2019, 12:58:41 AM (5 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 8 8 GraphicTest.lps 9 9 GraphicTest.dbg 10 heaptrclog.trc
-
- Property svn:ignore
-
GraphicTest/Packages/bgrabitmap/bgracolorquantization.pas
r494 r521 41 41 FSeparateAlphaChannel: boolean; 42 42 procedure Init(ABox: TBGRAColorBox); 43 procedure NormalizeArrayOfColors(AColors: ArrayOfTBGRAPixel; ARedBounds, AGreenBounds, ABlueBounds, AAlphaBounds: TDimensionMinMax; AUniform: boolean); 44 procedure NormalizeArrayOfColors(AColors: ArrayOfTBGRAPixel; AColorBounds, AAlphaBounds: TDimensionMinMax); 43 procedure NormalizeArrayOfColors(AColors: ArrayOfTBGRAPixel; ARedBounds, AGreenBounds, ABlueBounds, AAlphaBounds: TDimensionMinMax; AUniform: boolean); overload; 44 procedure NormalizeArrayOfColors(AColors: ArrayOfTBGRAPixel; AColorBounds, AAlphaBounds: TDimensionMinMax); overload; 45 45 protected 46 46 function GetPalette: TBGRACustomApproxPalette; override; … … 56 56 destructor Destroy; override; 57 57 procedure ApplyDitheringInplace(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; ABounds: TRect); override; 58 function GetDitheredBitmap(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; ABounds: TRect): TBGRACustomBitmap; over ride;58 function GetDitheredBitmap(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; ABounds: TRect): TBGRACustomBitmap; overload; override; 59 59 function GetDitheredBitmapIndexedData(ABitDepth: integer; AByteOrder: TRawImageByteOrder; AAlgorithm: TDitheringAlgorithm; 60 ABitmap: TBGRACustomBitmap; out AScanlineSize: PtrInt): Pointer; over ride;60 ABitmap: TBGRACustomBitmap; out AScanlineSize: PtrInt): Pointer; overload; override; 61 61 procedure SaveBitmapToStream(AAlgorithm: TDitheringAlgorithm; 62 62 ABitmap: TBGRACustomBitmap; AStream: TStream; AFormat: TBGRAImageFormat); override; … … 228 228 implementation 229 229 230 uses BGRADithering, FPimage, FPWriteBMP, BGRAWritePNG ;230 uses BGRADithering, FPimage, FPWriteBMP, BGRAWritePNG, math; 231 231 232 232 const MedianMinPercentage = 0.2; … … 1131 1131 begin 1132 1132 FLeafColorComputed := true; 1133 FCenterColor.alpha:= FLeaf.FBounds[cdAlpha].GetCenter shr AlphaShift;1134 FCenterColor.red:= GammaCompressionTab[ FLeaf.FBounds[cdRed].GetCenter shr RedShift];1135 FCenterColor.green:= GammaCompressionTab[ FLeaf.FBounds[cdGreen].GetCenter shr GreenShift];1136 FCenterColor.blue:= GammaCompressionTab[ FLeaf.FBounds[cdBlue].GetCenter];1133 FCenterColor.alpha:= min(FLeaf.FBounds[cdAlpha].GetCenter shr AlphaShift, 255); 1134 FCenterColor.red:= GammaCompressionTab[min(FLeaf.FBounds[cdRed].GetCenter shr RedShift, 65535)]; 1135 FCenterColor.green:= GammaCompressionTab[min(FLeaf.FBounds[cdGreen].GetCenter shr GreenShift, 65535)]; 1136 FCenterColor.blue:= GammaCompressionTab[min(FLeaf.FBounds[cdBlue].GetCenter, 65535)]; 1137 1137 FAverageColor := FLeaf.AverageColorOrMainColor; 1138 1138 extremumColor := FAverageColor;
Note:
See TracChangeset
for help on using the changeset viewer.