Can I cast BYTE* to char* , or BYTE* to CString and then back to BYTE ? What should I use for that ?
ninck
Posts
-
BYTE* to char* or BYTE* to CString ? -
Why does my SetDIBColorTable fail ?So how do I create a 256 color DC ?
-
Why does my SetDIBColorTable fail ?The return value for my SetDIBColorTable() function call is 0 (zero), so the function failed . Why ? Here's the source code : HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, m_handlerToBMP); RGBQUAD pColors[256]; //RGBQUAD *oldpColors; for(int i=0; i<256; ++i) { pColors[i].rgbRed = i; pColors[i].rgbBlue = i; pColors[i].rgbGreen = i; pColors[i].rgbReserved = 0; } //pColors1=pColors; //GetDIBColorTable(hMemDC, 0, 256, oldpColors); UINT aaa=SetDIBColorTable(hMemDC,0,255,pColors);
-
Display DIB when I have its handle (HBITMAP)Well that's what I did ,basically . As you can see bellow I also have a function which makes my DIB from a DDB(the funnction is ConvertToDIB).I called this function before the SelectObject call .I don't know why I can't display the DIB (I see a white window when I try to open an image). I transformed the DDB into DIB so I can modify it (for now I don't know how to modify it , but I just want to display it first ).Here's the code : void CDoiView::OnInitialUpdate() { CScrollView::OnInitialUpdate(); CSize sizeTotal; sizeTotal.cx = sizeTotal.cy = 0; CleanUp(); CDoiDoc* pDoc = GetDocument(); CString strPath = pDoc->GetPathName(); if (!strPath.IsEmpty()) m_handlerToBMP = GetBitmapFromFile(strPath); if (m_handlerToBMP){ GetBitmapDimensionEx(m_handlerToBMP, &sizeTotal); } SetScrollSizes(MM_TEXT, sizeTotal); CDC* pDC=GetDC(); HDC hMemDC; hMemDC=CreateCompatibleDC(pDC->GetSafeHdc()); if (hMemDC) { if (m_handlerToBMP){ bool aa; if ( (aa=ConvertToDIB(m_handlerToBMP))==false ) { AfxMessageBox("eroare ConvertToDIB");} // select new bitmap into memory DC HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, m_handlerToBMP); //alocam memorie pentru tabloul ce contine informatia despre culoarea pixelilor GetBitmapDimensionEx(m_handlerToBMP, &sizeTotal); //transfer din memorie in fereastra ::BitBlt(pDC->GetSafeHdc(),0,0,sizeTotal.cx,sizeTotal.cy,hMemDC,0,0,SRCCOPY); // select old bitmap back into memory DC and get handle to bitmap SelectObject(hMemDC, hOldBitmap); DeleteObject(hOldBitmap); DeleteDC(hMemDC); } Invalidate(); UpdateWindow(); } }
-
Display DIB when I have its handle (HBITMAP)What's the easiest way to display a DIB when I have its handle which is a HBITMAP ? I found some functions which display it (the DIB) but for those I need some parameters which I don't have. I need a function, or member function of some class which would display it taking as argument the handle to the DIB (the HBITMAP), and the position .