Programatically create Bitmap file: How To???
-
Hi i am doing following: From my function SaveAsBitmap
CClientDC dc(this); MemDC.Detach (); MemDC.CreateCompatibleDC(&dc); m_WfrBmp.Detach (); m_WfrBmp.CreateCompatibleBitmap(&dc, 860, 1100); CBitmap *pOldBitmap = (CBitmap *)MemDC.SelectObject(&m_WfrBmp); MemDC.SetMapMode(MM_LOENGLISH); // MemDC.PatBlt(0, 0, 860, 1100, WHITENESS); MemDC.SetBkMode (TRANSPARENT); MemDC.SetBkColor (RGB(255,255,255)); MemDC.Rectangle (100,100,400,400); // Now save the bitmap to the BMP file Filename ="C:\\12.bmp"; CDIBSectionLite dib; HBITMAP hnd = (HBITMAP)m_WfrBmp.GetSafeHandle (); dib.SetBitmap (hnd); dib.Save(Filename);
I am getting Black bitmaps only..... What is the problem... Any help/suggestions Leave your mark wherever you go -
Hi i am doing following: From my function SaveAsBitmap
CClientDC dc(this); MemDC.Detach (); MemDC.CreateCompatibleDC(&dc); m_WfrBmp.Detach (); m_WfrBmp.CreateCompatibleBitmap(&dc, 860, 1100); CBitmap *pOldBitmap = (CBitmap *)MemDC.SelectObject(&m_WfrBmp); MemDC.SetMapMode(MM_LOENGLISH); // MemDC.PatBlt(0, 0, 860, 1100, WHITENESS); MemDC.SetBkMode (TRANSPARENT); MemDC.SetBkColor (RGB(255,255,255)); MemDC.Rectangle (100,100,400,400); // Now save the bitmap to the BMP file Filename ="C:\\12.bmp"; CDIBSectionLite dib; HBITMAP hnd = (HBITMAP)m_WfrBmp.GetSafeHandle (); dib.SetBitmap (hnd); dib.Save(Filename);
I am getting Black bitmaps only..... What is the problem... Any help/suggestions Leave your mark wherever you goget your header info and write your bitmap pixel per pixel (binary so use fwrite) NOTE: write away like BGR and NOT RGB. For some reason it is that way. (think memory access time is the reason, but I'm not sure) Find some info on the net about the structure of a bmp file. good luck. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
-
Hi i am doing following: From my function SaveAsBitmap
CClientDC dc(this); MemDC.Detach (); MemDC.CreateCompatibleDC(&dc); m_WfrBmp.Detach (); m_WfrBmp.CreateCompatibleBitmap(&dc, 860, 1100); CBitmap *pOldBitmap = (CBitmap *)MemDC.SelectObject(&m_WfrBmp); MemDC.SetMapMode(MM_LOENGLISH); // MemDC.PatBlt(0, 0, 860, 1100, WHITENESS); MemDC.SetBkMode (TRANSPARENT); MemDC.SetBkColor (RGB(255,255,255)); MemDC.Rectangle (100,100,400,400); // Now save the bitmap to the BMP file Filename ="C:\\12.bmp"; CDIBSectionLite dib; HBITMAP hnd = (HBITMAP)m_WfrBmp.GetSafeHandle (); dib.SetBitmap (hnd); dib.Save(Filename);
I am getting Black bitmaps only..... What is the problem... Any help/suggestions Leave your mark wherever you go -
Hi i am doing following: From my function SaveAsBitmap
CClientDC dc(this); MemDC.Detach (); MemDC.CreateCompatibleDC(&dc); m_WfrBmp.Detach (); m_WfrBmp.CreateCompatibleBitmap(&dc, 860, 1100); CBitmap *pOldBitmap = (CBitmap *)MemDC.SelectObject(&m_WfrBmp); MemDC.SetMapMode(MM_LOENGLISH); // MemDC.PatBlt(0, 0, 860, 1100, WHITENESS); MemDC.SetBkMode (TRANSPARENT); MemDC.SetBkColor (RGB(255,255,255)); MemDC.Rectangle (100,100,400,400); // Now save the bitmap to the BMP file Filename ="C:\\12.bmp"; CDIBSectionLite dib; HBITMAP hnd = (HBITMAP)m_WfrBmp.GetSafeHandle (); dib.SetBitmap (hnd); dib.Save(Filename);
I am getting Black bitmaps only..... What is the problem... Any help/suggestions Leave your mark wherever you goI hope there is nothing attched before you make those calls to Detach() or your program will have resource leaks. After drawing to the bitmap via Rectangle, select pOldBitmap into MemDC. If either function SetBitmap() or Save() needs to select it into a DC, then neither one can do it until MemDC releases ownership. A bitmap can only be selected into one DC at a time. INTP