Thanks for the link Xirax.
Here is a new version of BGRABitmap 8.0.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.0.zip/downloadBox blurA very fast blur is available. It is "box blur", where the area around a pixel is blurred as a square. You can use it with:
- text effects (set ShadowQuality:= rbBox)
- FilterBlurRadial (use rbBox as blur type)
- Canvas2d (set shadowFastest:= true)
3d renderingIt is essentially an upgrade to support more OBJ files :
- it is possible now to define custom normals
- negative vertex reference has been added
- loading materials from MTL file (using LoadMaterialsFromFileUTF8 function)
Often, the material file has the same name as the object file, so you can get the correct filename:
materialFilename := ChangeFileExt(objectFilename,'.mtl')
Color quantizationThis goes with new classes to handle palettes. In BGRAPalette unit, there are different kind of palettes. The types you are likely to create are :
- TBGRAPalette: a palette where you can add and remove colors
- TBGRAWeightedPalette: a palette where each color has a weight. So if you add the same color multiple times, its weight increases
In order to reduce the number of colors or to save a bitmap to a file with a small number of colors, the class TBGRAColorQuantizer is available BGRAColorQuantization unit.
First instantiate TBGRAColorQuantizer with a bitmap or a palette. It will procude a reduced palette. The maximum number of color in this palette is defined by the property ReductionColorCount (by default 256). There are different ways to handle transparency, indicated by TAlphaChannelPaletteOption :
- acIgnore: it means alpha channel is considered separately from the color
- acTransparentEntry: it means that one entry in the palette will be the transparent color, with alpha = 0
- acFullChannelInPalette: it means that there will be if necessary a gradient of alpha values represented in the palette (this is recommended for example if you save in PNG format)
Here is for example how you would produce a 256 color PNG file:
uses BGRAColorQuantization, BGRABitmapTypes, BGRABitmap;
var
quant : TBGRAColorQuantizer;
sourceBmp: TBGRABitmap;
begin
sourceBmp := TBGRABitmap.Create('picture_in_32_bits.bmp');
quant := TBGRAColorQuantizer.Create(sourceBmp, acFullChannelInPalette);
quant.SaveBitmapToFile(daFloydSteinberg, sourceBmp, 'picture_in_8_bits.png');
quant.Free;
sourceBmp.Free;
end;
Here is for example how you would produce a 16 color BMP file:
uses BGRAColorQuantization, BGRABitmapTypes, BGRABitmap;
var
quant : TBGRAColorQuantizer;
sourceBmp: TBGRABitmap;
begin
sourceBmp := TBGRABitmap.Create('picture.jpg');
quant := TBGRAColorQuantizer.Create(sourceBmp, acIgnore);
quant.ReductionColorCount := 16;
quant.SaveBitmapToFile(daFloydSteinberg, sourceBmp, 'picture_in_4_bits.bmp');
quant.Free;
sourceBmp.Free;
end;