Главная страница
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.035 c
3-1106583349
Вован_
2005-01-24 19:15
2005.02.20
Как сохранить изображение из .bmp в поле Graphic через TQuery?


3-1106567881
Alx2
2005-01-24 14:58
2005.02.20
Вычислимое поле в запросе


1-1107928317
Gloomer
2005-02-09 08:51
2005.02.20
Ошибка при использовании DLL


1-1107778456
Ega23
2005-02-07 15:14
2005.02.20
Поясните ситуацию с StrPCopy


4-1105200919
Лёха
2005-01-08 19:15
2005.02.20
BITMAP