Click here to Skip to main content
15,922,574 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bit operation question Pin
Martin Ziacek1-Nov-01 6:55
Martin Ziacek1-Nov-01 6:55 
GeneralRe: Bit operation question Pin
1-Nov-01 7:04
suss1-Nov-01 7:04 
GeneralRe: Bit operation question Pin
Martin Ziacek1-Nov-01 7:44
Martin Ziacek1-Nov-01 7:44 
GeneralRe: Bit operation question Pin
Chris Losinger1-Nov-01 7:44
professionalChris Losinger1-Nov-01 7:44 
Generalone with arithmetic operators: Pin
Chris Losinger1-Nov-01 7:52
professionalChris Losinger1-Nov-01 7:52 
GeneralRe: one with arithmetic operators: Pin
Alvaro Mendez1-Nov-01 7:57
Alvaro Mendez1-Nov-01 7:57 
GeneralRe: one with arithmetic operators: Pin
Chris Losinger1-Nov-01 7:58
professionalChris Losinger1-Nov-01 7:58 
GeneralDIBS and "the bits" Pin
Chambers1-Nov-01 5:11
Chambers1-Nov-01 5:11 
Hi all, I have managed to load/create (as necessary) a 24-bit DIBSection using the means described on this very web site (LR_CREATEDIBSECTION flag in LoadImage and CreateDIBSection), both of which return a HBITMAP. Superb. What I want to do now is "grab" the actual BGR colour values that make up each pixel, and change them to something else such as RGB(0,255,0 - Green, its the easiest example to use). At the moment I am trying to get the bits using a BITMAP structure (returned through GetObject) and its bmBits property. I have also implemented Christians wizardry to convert this pointer to a valid LPBYTE by :

for (int y=0, y < bm.bmHeight, y++)
{
  LPBYTE pbSrcRGB = (LPBYTE)&((DWORD*)pDestBits)[y*bm->bmWidth]
  for (int x=0, x < bm.bmWidth, x++)
  {
    pbSrcRGB[0]=0
    pbSrcRGB[1]=255
    pbSrcRGB[2]=0
    pbSrcRGB+=3
  }
}


However, the program crashes out after a few laps of the for loops. I have also checked to see whats in pbSrcRGB at position [0] BEFORE assignment and every time it has :

0 ''

it is NULL terminated. How is this remedied? BITMAP structure is passed into this function by :

&bm

and a LPBITMAP structure is then used (as you can see from bm->), so I would have thought that everything was OK from the BITMAP point of view. Also the bitmap starts off black (which I don`t want, thats why I`m changing it all to green), so I assume this is why it reads 0 ''. Also when I check pbSrcRGB[0] to see what it contains AFTER assignment, it reads :

255 'y' (with funny line over the top of the y)

Why does this happen?

The main essence of my questions are aimed at discovering :
a) why the program could be crashing out.
b) why the pixel colours on the screen don`t change when the memDC is blit to pDC (the screen device context).

Any help would be hugely appreciated as you can imagine. I`ve been working on this for a while, and just can`t figure it out. I`ve checked a lot of articles, but to this day I can`t find one that even attempts to shed light on the situation (except Christians - but the article didn`t really target the issue). If you`ve read this far down, I thank you for that even if you don`t know the answer,

Cheers,Confused | :confused: Mad | :mad: Confused | :confused:
Alan.

P.S. On a slightly different aspect, is there anyway of creating a DIB and intialising its colour to white instead of black?

AEGC
GeneralRe: DIBS and "the bits" Pin
Chris Losinger1-Nov-01 5:21
professionalChris Losinger1-Nov-01 5:21 
GeneralRe: DIBS and "the bits" Pin
Chambers1-Nov-01 5:36
Chambers1-Nov-01 5:36 
GeneralRe: DIBS and "the bits" Pin
Chris Losinger1-Nov-01 5:57
professionalChris Losinger1-Nov-01 5:57 
GeneralRe: DIBS and "the bits" - Chris Please Read Pin
Chambers1-Nov-01 6:12
Chambers1-Nov-01 6:12 
GeneralRe: DIBS and "the bits" - Chris Please Read Pin
Chris Losinger1-Nov-01 6:58
professionalChris Losinger1-Nov-01 6:58 
GeneralRe: DIBS and "the bits" - Solution Pin
Chambers1-Nov-01 7:33
Chambers1-Nov-01 7:33 
GeneralAccelerator Keys Pin
Özgür1-Nov-01 4:51
Özgür1-Nov-01 4:51 
Generalsorting std::vector Pin
User 98851-Nov-01 4:23
User 98851-Nov-01 4:23 
GeneralRe: sorting std::vector Pin
Chris Losinger1-Nov-01 4:29
professionalChris Losinger1-Nov-01 4:29 
GeneralRe: sorting std::vector Pin
User 98851-Nov-01 4:33
User 98851-Nov-01 4:33 
GeneralRe: sorting std::vector Pin
Todd Smith1-Nov-01 5:46
Todd Smith1-Nov-01 5:46 
GeneralRational Rose Pin
1-Nov-01 2:59
suss1-Nov-01 2:59 
GeneralRe: Rational Rose Pin
Fredy21-Feb-02 6:19
Fredy21-Feb-02 6:19 
QuestionGive me advice how to start in OpenGL? Pin
1-Nov-01 2:42
suss1-Nov-01 2:42 
AnswerRe: Give me advice how to start in OpenGL? Pin
Roger Allen1-Nov-01 3:40
Roger Allen1-Nov-01 3:40 
AnswerRe: Give me advice how to start in OpenGL? Pin
Jonathan de Halleux1-Nov-01 5:12
Jonathan de Halleux1-Nov-01 5:12 
AnswerRe: Give me advice how to start in OpenGL? Pin
Carlos Antollini1-Nov-01 5:42
Carlos Antollini1-Nov-01 5:42 

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.