Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Member 9255349

@Member 9255349
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Accessing Pixels with CreateDIBSection
    M Member 9255349

    Thank you!

    C / C++ / MFC graphics help question

  • Accessing Pixels with CreateDIBSection
    M Member 9255349

    Thanks so much for the quick reply. You are a lifesaver! (Or... at least a sleep saver.) :)

    C / C++ / MFC graphics help question

  • Accessing Pixels with CreateDIBSection
    M Member 9255349

    Hello all. I am new to image processing and am having trouble with CreateDIBSection. I have been reading other threads on this topic and code snippets for several days now, so I was hoping at this point to get specific help with my code rather than a link to a previous explanation or code. I have a dialog based app. I want to take a screen shot, change some of the pixel colors and BitBlt it back. In my attempt to make a rectangle of red pixels (or any color) that is 800 pixels in width and 900 in height, I end up with 4 rectangles that are 200 pixels in width and 225 pixels in height, that are separated by 36 pixels and that are alternating is color between red a blue. I'm guessing that this has something to do with the padding. I'd really appreciate an help you can offer!

        CDC\* pDC=GetDC();
    HDC hDC = \*pDC;
    HDC hDCMem = CreateCompatibleDC(hDC);
    
    BYTE\* lpBitmapBits = NULL; 
    
    BITMAPINFO bi; 
    ZeroMemory(&bi, sizeof(BITMAPINFO));
    bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bi.bmiHeader.biWidth = m\_rcMainRect.Width();
    bi.bmiHeader.biHeight = -m\_rcMainRect.Height();
    bi.bmiHeader.biPlanes = 1;
    bi.bmiHeader.biBitCount = 32;
    
    HBITMAP bitmap = ::CreateDIBSection(hDCMem, &bi, DIB\_RGB\_COLORS, (LPVOID\*)&lpBitmapBits, NULL, 0);
    HGDIOBJ oldbmp = ::SelectObject(hDCMem, bitmap); 
    
    BitBlt(hDCMem, 0, 0, m\_rcMainRect.Width(), m\_rcMainRect.Height(), hDC, 0, 0, SRCCOPY);
    
    
    for(int x=0; x<800; x=x+4)
    {
    	for(int y=0; y<900; y++)
    	{
    	lpBitmapBits\[(y\*m\_rcMainRect.Width())+x\] = 0x00;    //alpha channel?
    	lpBitmapBits\[(y\*m\_rcMainRect.Width())+x+1\] = 0x00;
    	lpBitmapBits\[(y\*m\_rcMainRect.Width())+x+2\] = 0xFF;
    	lpBitmapBits\[(y\*m\_rcMainRect.Width())+x+3\] = 0x00;
    	}
    }
    
    BitBlt(hDC, 0, 0, m\_rcMainRect.Width(), m\_rcMainRect.Height(), hDCMem, 0, 0, SRCCOPY);
    
        SelectObject(hDCMem,oldbmp);  
        DeleteDC(hDCMem);  
        DeleteObject(bitmap);
    
    C / C++ / MFC graphics help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups