SetPixel and Color Issue
Hi Ran,
I am also facing the same color problem with SetPixels that you have mentioned. Could you please let me know the solution for this.
Thanks,
RAN wrote:
Re: SetPixel and Color
17-May-08
On 16 mei, 23:35, Joseph M. Newcomer <newco...@flounder.com> wrote:
E=ADPAWN),RT_BITMAP)));
f any of these
how are we to
ber to use
d we believe it? Did
ff || *(po_Bitmap + 1) != 0xff ||
n_X+nX,n_Y+nY,RGB(*(po_Bitmap),*(po_Bitmap
les of four.
itBlt? If you
a data bitmap,
hite where you
The GetDIBits is
hink the correct
loops at all.
Thanks! I think i found a sample on the net about this technique.
Previous Posts In This Thread:
On Friday, May 16, 2008 5:35 PM
Joseph M. Newcomer wrote:
Re: SetPixel and Color
See below...
On Fri, 16 May 2008 13:34:39 -0700 (PDT), RAN <nijenhuis@wish.nl> wrote:
****
These operations should not be compounded like this. You have no idea if any of these
succeed.
****
****
I note that you did not tell us what the declaration of po_StartBitmap is; how are we to
make sense of this assignment?
****
****
Do not use commas in declaration lists, and if you feel you have to, remember to use
whitespace to make code readable.
****
*****
How do you know it is 40? Where did this number come from? Why should we believe it? Did
not not mean sizeof() of some well-defined structure?
****
****
This loop is about the clumsiest thing I've seen in a long time. Why not BitBlt? If you
need something that is transparent, create two bitmaps: a mask bitmap and a data bitmap,
and do two BitBlts, one which ANDs the mask (black where you want color, white where you
want background) and ORs the data (black where you want transparency). The GetDIBits is
irrelevant here. You've been going after the wrong solution.
****
****
Blue is the complement of yellow. That should suggest something.But I think the correct
answer is not to fix this code, but to write better code that involves no loops at all.
joe
****
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
On Saturday, May 17, 2008 7:48 AM
RAN wrote:
SetPixel and Color
Hello,
I have loaded a bitmap resource using:
..
..
..
po_StartBitmap[6] =(BYTE*)
LockResource(LoadResource(NULL,FindResource(NULL,MAKEINTRESOURCE(IDB_WHITEPAWN),RT_BITMAP)));
I probably should have done this using GetDIBits() but i could not get
it to work just now, so i tried this instead.
It does what i want, getting a pointer to the bitmapdata, may try
GetDIBits() later.
I want to draw the bitmap in OnDraw() using SetPixel().
Like so:
void CPGNFENEditorView::Draw_WhitePawn(int n_X, int n_Y, CDC *po_dc)
{
BYTE* po_Bitmap;
po_Bitmap = po_StartBitmap[6];
int nWidth =55;
int nHeight =64;
int nX,nY;
po_Bitmap+=40; // start pixeldata
for(nY = 0; nY < nHeight; nY ++)
{
for(nX = 0; nX < nWidth; nX++)
{
if( *(po_Bitmap ) != 0xff || *(po_Bitmap + 1) != 0xff ||
*(po_Bitmap + 2) != 0xff)
po_dc->SetPixel (n_X+nX,n_Y+nY,RGB(*(po_Bitmap),*(po_Bitmap
+1),*(po_Bitmap+2)));
po_Bitmap+=3;
}
po_Bitmap+=3; // skip trailing zeros for multiples of four.
}
}
I have a bitmap with a black king (chesspiece) which is black, this
bitmap is drawn perfectly using the SetPixel() code. (Its black and
the shape is what it should be)
Then i have a bitmap with a white king which is actually yellow in
color.
The above code displayes the bitmap perfectly, BUT its not yellow but
blue!
How can the bitmap be displayed perfectly but be of a different color
than it originally is?
On Saturday, May 17, 2008 7:48 AM
RAN wrote:
Re: SetPixel and Color
On 16 mei, 23:35, Joseph M. Newcomer <newco...@flounder.com> wrote:
E=ADPAWN),RT_BITMAP)));
f any of these
how are we to
ber to use
d we believe it? Did
ff || *(po_Bitmap + 1) != 0xff ||
n_X+nX,n_Y+nY,RGB(*(po_Bitmap),*(po_Bitmap
les of four.
itBlt? If you
a data bitmap,
hite where you
The GetDIBits is
hink the correct
loops at all.
Thanks! I think i found a sample on the net about this technique.
Submitted via EggHeadCafe - Software Developer Portal of Choice
html mailto attribute usages
http://www.eggheadcafe.com/tutorials/aspnet/ea4b454c-2b52-4af4-b623-fbd259f7d5de/html-mailto-attribute-usa.aspx