Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2005.02.20;
Скачать: [xml.tar.bz2];

Вниз

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

 
Сергей+   (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 вся ветка

Форум: "WinAPI";
Текущий архив: 2005.02.20;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.049 c
1-1107390335
RamZeS
2005-02-03 03:25
2005.02.20
Как возвратить TStrings из dll?


6-1102148567
CBOLOCH
2004-12-04 11:22
2005.02.20
FTP


3-1106329006
Руслана
2005-01-21 20:36
2005.02.20
Вопрос по SQL запросу


14-1107278045
Шишкин Илья
2005-02-01 20:14
2005.02.20
PocketPC


8-1099136406
Tatarin
2004-10-30 15:40
2005.02.20
MP2 MP3





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский