Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.02.20;
Скачать: CL | DM;

Вниз

Инвертирование цвета   Найти похожие ветки 

 
Сергей+   (2005-01-03 16:31) [0]

Всем привет !

есть задача:
нужно проинвертировать заданный цвет.
Хотелось бы найти чтонибудь системное, чтобы самому не   обрабатывать множество форматов цвета.
////
например, если рисовать линию в режиме
canvas.pen.mode:=pmNot
то винда как-раз делает эту задачу.

заранее спасиба


 
programania ©   (2005-01-03 19:45) [1]

C:=RGB(255-GetRValue(C),255-GetGValue(C),255-GetBValue(C));


 
R.D.I. ©   (2005-01-03 19:51) [2]


var
 C: TColor;
begin
...
C:=16777215 - C;
...
end;


 
Anatoly Podgoretsky ©   (2005-01-03 20:21) [3]

C := C XOR $FFFFFF


 
Asteroid ©   (2005-01-04 01:30) [4]

Смотря как надо инвертировать. Если в нормальном смысле - то [1]-[3]. Если так, чтобы была как можно большая разница в цвете между прямым и инвертированным - то C := C xor $808080. (сравни с [3] на сером цвете типа $7F7F7F).


 
Сергей+   (2005-01-04 10:11) [5]

спасибо за советы.
но это малость не то.

откуда вы знаете что цвет в формате $00BBGGRR

у битмапа есть дофиг форматов:
TPixelFormat = (pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit)
и у винды всякие настройки глубины цвета ......

не хотелось бы делать надцать переборов :(


 
GrayFace ©   (2005-01-04 16:05) [6]

Вот как раз TBitmap гарантирует формат $BBGGRR, иначе надо было бы делать ColorToRGB. Canvas.Pixels все переводит в нормальный TColor.


 
ivane   (2005-01-04 18:36) [7]

Попробуй просто копирование чисто белого или чисто чёрного битмапа на твой исходный(того же размера) с использованием логических операций....

Вырезка из Хелпа(TCanvas.CopyMode)



TCopyMode specifies how a graphical image is copied onto a canvas.

Unit

Graphics

Delphi syntax:

type TCopyMode = Longint;

C++ syntax:

typedef int TCopyMode;

Description

TCopyMode values describe how to combine the colors of a source bitmap and a destination bitmap.

The Windows unit defines the following constants for TCopyMode values:

Value Meaning

cmBlackness Fills the destination rectangle on the canvas with black.
cmDstInvert Inverts the image on the canvas and ignores the source.
cmMergeCopy Combines the image on the canvas and the source bitmap by using the Boolean AND operator.
cmMergePaint Combines the inverted source bitmap with the image on the canvas by using the Boolean OR operator.
cmNotSrcCopy Copies the inverted source bitmap to the canvas.
cmNotSrcErase Combines the image on the canvas and the source bitmap by using the Boolean OR operator, and inverts the result.

cmPatCopy Copies the source pattern to the canvas.
cmPatInvert Combines the source pattern with the image on the canvas using the Boolean XOR operator
cmPatPaint Combines the inverted source bitmap with the source pattern by using the Boolean OR operator. Combines the result of this operation with the image on the canvas by using the Boolean OR operator.
cmSrcAnd Combines the image on the canvas and source bitmap by using the Boolean AND operator.
cmSrcCopy Copies the source bitmap to the canvas.

cmSrcErase Inverts the image on the canvas and combines the result with the source bitmap by using the Boolean AND operator.
cmSrcInvert Combines the image on the canvas and the source bitmap by using the Boolean XOR operator.
cmSrcPaint Combines the image on the canvas and the source bitmap by using the Boolean OR operator.
cmWhiteness Fills the destination rectangle on the canvas with white.



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

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

Наверх




Память: 0.48 MB
Время: 0.086 c
1-1107347080
Dmitry_04
2005-02-02 15:24
2005.02.20
Скинообразная форма непрямоугольногоя


4-1104852362
Эдик
2005-01-04 18:26
2005.02.20
Как получить список модомов Win 95/98/2000/XP


1-1107263086
BaDeVlad
2005-02-01 16:04
2005.02.20
Несворачиваемое окно


4-1104318307
Pavlik_Morozov
2004-12-29 14:05
2005.02.20
Как вызвать DPtoLP для точек из метафайла (TMetaFile)?


4-1104671073
lexusU
2005-01-02 16:04
2005.02.20
Как зарегистрировать и запустить/остановить службу?