T O P I C R E V I E W |
AndyColmes |
Posted - Oct 04 2018 : 16:29:33 I have this function but it uses TBitmap. I tried changing it to TIEBitmap but it gives an error in the Palette:
procedure SetBitmap8bitPalette(const Palette: T8bitPaletteArray; Bitmap: TBitmap); // Add a 256-color palette to a bitmap var i, y: integer; pal: PLogPalette; hpal: HPALETTE; begin if not assigned(Bitmap) then exit; // 8 bits per pixel Bitmap.PixelFormat := pf8bit;
// Create a gradient palette between foreground and background color GetMem(pal, sizeof(TLogPalette) + sizeof(TPaletteEntry) * 256); try pal.palVersion := $300; pal.palNumEntries := 256; for i := 0 to 255 do begin pal.palPalEntry[i].peRed := Palette[i].R; pal.palPalEntry[i].peGreen := Palette[i].G; pal.palPalEntry[i].peBlue := Palette[i].B; end; hpal := CreatePalette(pal^); if hpal <> 0 then Bitmap.Palette := hpal; <--- Error! finally FreeMem(pal); end;
// Fill bitmap with background color for y := 0 to Bitmap.Height - 1 do FillChar(Bitmap.Scanline[y]^, Bitmap.Width, 0); end;
I appreciate any help you can offer. Thank you in advance.
Andy
|
4 L A T E S T R E P L I E S (Newest First) |
xequte |
Posted - Oct 05 2018 : 00:30:35 Hi Andy
The third overload accepts Palette as an array of TRGB:
function ConvertTo(PixelFormat: TIEPixelFormat; Palette: array of TRGB; DitherType: TIEDitherType = iedtSolid; CheckParametersOnly: boolean = false): boolean; overload;
So you can assign your TBitmap to a TIEBitmap, convert your T8bitPaletteArray to an array of TRGB then call:
ImageEnView1.Proc.ConvertTo(ie8p, MYPALETTE, iedtErrorDiffusion); ImageEnView1.IO.Params.BitsPerSample := 8; ImageEnView1.IO.Params.SamplesPerPixel := 1;
If you just want a general 256 color palette, use:
ImageEnView1.Proc.ConvertTo(256);
Nigel Xequte Software www.imageen.com
|
AndyColmes |
Posted - Oct 04 2018 : 23:40:07 Right now, I have to create a TBitmap, run SetBitmap8bitPalette on it and then assign it to a TIEBitmap which I think increases overhead and gives "not enough storage" memory error when dealing with large images |
AndyColmes |
Posted - Oct 04 2018 : 23:13:24 Hi Nigel,
Thanks for the info. What would be the values to use the ConvertTo function to do what the SetBitmap8bitPalette does?
Thanks again.
Andy
|
xequte |
Posted - Oct 04 2018 : 20:11:24 Hi Andy
Firstly, have you considered just using the built in ImageEn methods for this:
https://www.imageen.com/help/TImageEnProc.ConvertTo.html
Nigel Xequte Software www.imageen.com |