Click here to Skip to main content
15,905,607 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: unsigned char Pin
Nemanja Trifunovic24-Dec-05 10:09
Nemanja Trifunovic24-Dec-05 10:09 
GeneralRe: unsigned char Pin
segment_fault3-Jan-06 18:02
segment_fault3-Jan-06 18:02 
QuestionTo Delete Objects created by IMPLEMENT_DYNACREATE Pin
birajendu22-Dec-05 23:38
birajendu22-Dec-05 23:38 
AnswerRe: To Delete Objects created by IMPLEMENT_DYNACREATE Pin
Sheng Jiang 蒋晟24-Dec-05 9:28
Sheng Jiang 蒋晟24-Dec-05 9:28 
QuestionRGBQUAD in Bitmap Class Pin
vikas amin22-Dec-05 23:29
vikas amin22-Dec-05 23:29 
AnswerRe: RGBQUAD in Bitmap Class Pin
toxcct22-Dec-05 23:46
toxcct22-Dec-05 23:46 
AnswerRe: RGBQUAD in Bitmap Class Pin
Russell'22-Dec-05 23:56
Russell'22-Dec-05 23:56 
AnswerRe: RGBQUAD in Bitmap Class Pin
Amal P23-Dec-05 0:23
Amal P23-Dec-05 0:23 
Hi,

Usually we creates the bitmap info directly from BITMAPINFO structure. But you can derive another structure from it. Then you will have access to RGBQUAD values. For knowing how to derive a structure from BITMAPINFO see the below code.


struct DIBINFO : public BITMAPINFO
{
RGBQUAD arColors[255]; // Adds an extra 255 entries to palette

operator LPBITMAPINFO() { return (LPBITMAPINFO) this; }
operator LPBITMAPINFOHEADER() { return &bmiHeader; }
RGBQUAD* ColorTable() { return bmiColors; }
};

Now instead of creating a Bitmap Info object of BITMAPINFO structure create it using DIBINFO structure. It is just simple as,

DIBINFO m_bitmapInfo;

Now you can change the RGBQUAD palette by changing the values in the arColors of the bitmap. For example here i am changing the palette to a gray scale one by filling same values at Blue, Green and Red.

for(int i = 0; i < 255; i++)
{
m_bitmapInfo.arColors[i].rgbBlue = i;
m_bitmapInfo.arColors[i].rgbGreen = i;
m_bitmapInfo.arColors[i].rgbRed = i;
m_bitmapInfo.arColors[i].rgbReserved = i;
}

There is another reserved member. It may be used in some other cases as Alpha. Normaly when you tell the color of a pixel you will specify 4 values.

They are,
1. Value of Red.
2. Value of Green.
3. Value of Blue.
4. Value of Alpha.
The alpha can be considered as the transparency.

Now while creating a bitmap pass the bitmap info as m_bitmapInfo. It will do the trick.


Thanks and Regards,
Amal P.
Question#if Pin
Smith#22-Dec-05 22:54
Smith#22-Dec-05 22:54 
AnswerRe: #if Pin
Owner drawn22-Dec-05 23:10
Owner drawn22-Dec-05 23:10 
GeneralRe: #if Pin
Smith#22-Dec-05 23:37
Smith#22-Dec-05 23:37 
AnswerRe: #if Pin
toxcct22-Dec-05 23:18
toxcct22-Dec-05 23:18 
GeneralRe: #if Pin
Smith#22-Dec-05 23:40
Smith#22-Dec-05 23:40 
GeneralRe: #if [edited] Pin
toxcct22-Dec-05 23:41
toxcct22-Dec-05 23:41 
GeneralRe: #if [edited] Pin
Eytukan23-Dec-05 0:37
Eytukan23-Dec-05 0:37 
AnswerRe: #if Pin
khan++22-Dec-05 23:35
khan++22-Dec-05 23:35 
GeneralRe: #if Pin
Smith#22-Dec-05 23:39
Smith#22-Dec-05 23:39 
GeneralRe: #if Pin
toxcct22-Dec-05 23:43
toxcct22-Dec-05 23:43 
GeneralRe: #if Pin
Smith#22-Dec-05 23:50
Smith#22-Dec-05 23:50 
GeneralRe: #if Pin
toxcct22-Dec-05 23:58
toxcct22-Dec-05 23:58 
GeneralRe: #if Pin
toxcct22-Dec-05 23:40
toxcct22-Dec-05 23:40 
GeneralRe: #if Pin
khan++22-Dec-05 23:53
khan++22-Dec-05 23:53 
GeneralRe: #if Pin
Smith#23-Dec-05 0:06
Smith#23-Dec-05 0:06 
GeneralRe: #if Pin
toxcct23-Dec-05 0:10
toxcct23-Dec-05 0:10 
GeneralRe: #if Pin
Smith#23-Dec-05 0:33
Smith#23-Dec-05 0:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.