Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionLost my way in classes and array.. Pin
joostvaningen1-Mar-06 0:50
joostvaningen1-Mar-06 0:50 
QuestionRe: Lost my way in classes and array.. Pin
David Crow1-Mar-06 2:58
David Crow1-Mar-06 2:58 
GeneralRe: Lost my way in classes and array.. Pin
joostvaningen1-Mar-06 3:37
joostvaningen1-Mar-06 3:37 
AnswerRe: Lost my way in classes and array.. Pin
joostvaningen1-Mar-06 20:42
joostvaningen1-Mar-06 20:42 
QuestionFile load in memoery memory - then perform read write on that data Pin
zahid_ash1-Mar-06 0:29
zahid_ash1-Mar-06 0:29 
AnswerRe: File load in memoery memory - then perform read write on that data Pin
Naveen1-Mar-06 2:17
Naveen1-Mar-06 2:17 
AnswerRe: File load in memoery memory - then perform read write on that data Pin
David Crow1-Mar-06 3:03
David Crow1-Mar-06 3:03 
QuestionSetBitmapBits not Working as Expected Pin
walter761-Mar-06 0:28
walter761-Mar-06 0:28 
Hi there,

i have written this function to draw a image held in raw pixel data in my own class to a window. It is not working as expected, say it doesn't draw a single pixel. Where is the fault? I am trying to solve this for days now and can't see where i made the mistake. Here comes the code.

void CImageViewerView::drawImage(CDC* pDC, CpilImage* pImage) {
    // create compatible memory dc
    CDC memDC;
    memDC.CreateCompatibleDC(pDC);

    // draw image into the bitmap
    CBitmap imageBitmap;
    BITMAP bmp;
    BYTE* imageBits;
    BYTE* pImageBits;

    imageBitmap.CreateBitmap(pImage->getWidth(), pImage->getHeight(), 1, 24, NULL);
    imageBitmap.GetBitmap(&bmp);
    imageBits = (BYTE*) GlobalAlloc(GPTR, bmp.bmHeight * bmp.bmWidthBytes);

    for (unsigned int y = 0; y < pImage->getHeight(); y++) {
        unsigned int* line = pImage->getPixelRegion(0, y, pImage->getWidth(), 1);
        unsigned int* pLine = line;

        pImageBits = imageBits + (bmp.bmWidthBytes * y);
        for (unsigned int x = 0; x < pImage->getWidth(); x++) {
            pImageBits[0] = getRedValue(pLine);
            pImageBits[1] = getGreenValue(pLine);
            pImageBits[2] = getBlueValue(pLine);
            pImageBits += 3;
            pLine++;
        }
    }
    if (imageBitmap.SetBitmapBits(bmp.bmHeight * bmp.bmWidthBytes, imageBits) == 0) {
        AfxMessageBox("Could not set bitmap bits.");
    }

    GlobalFree((HGLOBAL) imageBits);

    // draw bitmap
    CBitmap* pOldBitmap = memDC.SelectObject(&imageBitmap);
    if (pDC->BitBlt(0, 0, pImage->getWidth(), pImage->getHeight(), &memDC, 0, 0, SRCCOPY) ==0) {
        AfxMessageBox("BitBlt failed.");
    }
    memDC.SelectObject(pOldBitmap);
}


CpilImage is a class which stores a image plus the pixel data in rgb-quads. The getXXXValue()-functions are utility functions which extract the red, green and blue values from the quads. The class and functions are working, cause if i alter the function to work with CDC::SetPixelV() the image is drawn. But as this is very slow i tryed to speed it up with SetBitmapBits() and BitBlt() which seems to not work.

Walter
AnswerRe: SetBitmapBits not Working as Expected Pin
includeh101-Mar-06 2:11
includeh101-Mar-06 2:11 
GeneralRe: SetBitmapBits not Working as Expected Pin
walter761-Mar-06 2:25
walter761-Mar-06 2:25 
AnswerRe: SetBitmapBits not Working as Expected Pin
Ryan Binns1-Mar-06 2:53
Ryan Binns1-Mar-06 2:53 
GeneralRe: SetBitmapBits not Working as Expected Pin
walter761-Mar-06 2:59
walter761-Mar-06 2:59 
AnswerRe: SetBitmapBits not Working as Expected Pin
Ryan Binns1-Mar-06 2:55
Ryan Binns1-Mar-06 2:55 
GeneralRe: SetBitmapBits not Working as Expected Pin
walter761-Mar-06 3:00
walter761-Mar-06 3:00 
QuestionStatus bar part allignment Pin
Waldermort1-Mar-06 0:03
Waldermort1-Mar-06 0:03 
AnswerRe: Status bar part allignment Pin
Nibu babu thomas1-Mar-06 0:32
Nibu babu thomas1-Mar-06 0:32 
Questioncreating child process in c++ Pin
Aqueel28-Feb-06 23:58
Aqueel28-Feb-06 23:58 
AnswerRe: creating child process in c++ Pin
Nibu babu thomas1-Mar-06 0:03
Nibu babu thomas1-Mar-06 0:03 
AnswerRe: creating child process in c++ Pin
Vinaya1-Mar-06 0:08
Vinaya1-Mar-06 0:08 
AnswerRe: creating child process in c++ Pin
John R. Shaw1-Mar-06 0:23
John R. Shaw1-Mar-06 0:23 
AnswerRe: creating child process in c++ Pin
Cedric Moonen1-Mar-06 0:47
Cedric Moonen1-Mar-06 0:47 
GeneralRe: creating child process in c++ Pin
Ryan Binns1-Mar-06 2:58
Ryan Binns1-Mar-06 2:58 
AnswerRe: creating child process in c++ Pin
Aqueel1-Mar-06 0:48
Aqueel1-Mar-06 0:48 
GeneralRe: creating child process in c++ Pin
Ryan Binns1-Mar-06 2:59
Ryan Binns1-Mar-06 2:59 
AnswerRe: creating child process in c++ Pin
Nemanja Trifunovic1-Mar-06 1:48
Nemanja Trifunovic1-Mar-06 1:48 

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.