Вниз
Скачать: CL | DM;

Смена палитры в TGPImage --- GDI+   Найти похожие ветки 

← →
Andy BitOff ©   (2006-12-27 03:33) [0]

Загружаю *.tif как поменять палитру на монохромную (256 цветов)?


← →
Andy BitOff ©   (2007-01-03 20:33) [1]

Вот что получилось у меня:

procedure TForm1.ButtonClick(Sender: TObject);
var
 encoderClsid: TGUID;
 graphics: TGPGraphics;
 Image: TGPImage;
 ImageAttributes: TGPImageAttributes;
 width, height: Integer;
const
 colorMatrix : TColorMatrix  =
   ((0.3,  0.3,  0.3, 0.0, 0.0),
    (0.59,  0.59,  0.59, 0.0, 0.0),
    (0.11,  0.11,  0.11, 0.0, 0.0),
    (0.0,  0.0,  0.0, 1.0, 0.0),
    (0.0,  0.0,  0.0, 0.0, 1.0));
begin
 GetEncoderClsid("image/tiff", encoderClsid);
 Image := TGPImage.Create("1.tif");
 graphics := TGPGraphics.Create(Image);
 ImageAttributes := TGPImageAttributes.Create;
 try
   imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
   graphics.DrawImage(Image, MakeRect(0, 0, width, height),
                      0, 0, width, height,  UnitPixel, imageAttributes);
   image.Save("3.tif", encoderClsid);
 finally
   Image.Free;
   ImageAttributes.Free;
   graphics.Free;
 end;
end;

Но существует еще проблема. PixelFormat надо бы пивести к 8bits. Может кто знает?



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.014 c
2-1189928872
DimDim
2007-09-16 11:47
2007.10.14
Лишняя запятая в запросе


2-1189758230
shmelina
2007-09-14 12:23
2007.10.14
Показ формы-оповещения без фокуса


15-1189762734
vladislavmsk
2007-09-14 13:38
2007.10.14
Специальный TGroupBox


2-1189538649
SKIPtr
2007-09-11 23:24
2007.10.14
Удаление элементов в TStrings


2-1190098194
artem779
2007-09-18 10:49
2007.10.14
проблема с *.INI




   Наверх