Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.10.14;
Скачать: 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 вся ветка

Текущий архив: 2007.10.14;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.023 c
15-1189725749
delphiForever
2007-09-14 03:22
2007.10.14
и все таки я ее нашел...


2-1190299554
Dr. Andrew
2007-09-20 18:45
2007.10.14
Как при ошибке конвертирования выйти из процедуры?


15-1190107490
Сатир
2007-09-18 13:24
2007.10.14
Как посчитать кол-во часов, минут, секунд между двумя датами?


15-1190001542
Pazitron_Brain
2007-09-17 07:59
2007.10.14
Что вы делаете на работе?


3-1181203458
ina65
2007-06-07 12:04
2007.10.14
базы данных