Click here to Skip to main content
16,011,374 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGot it!!! Pin
el_robert2-Jul-02 12:47
el_robert2-Jul-02 12:47 
GeneralHelp Pin
2-Jul-02 9:41
suss2-Jul-02 9:41 
GeneralCalling between MFC classes Pin
2-Jul-02 9:39
suss2-Jul-02 9:39 
GeneralRe: Calling between MFC classes Pin
Dave Bryant2-Jul-02 11:17
Dave Bryant2-Jul-02 11:17 
Generaldetecting working and non-working links in a website Pin
2-Jul-02 8:50
suss2-Jul-02 8:50 
GeneralRe: detecting working and non-working links in a website Pin
2-Jul-02 10:46
suss2-Jul-02 10:46 
GeneralMDAC 2.7 problems. Please HELP. Pin
DimkaSPB2-Jul-02 8:10
DimkaSPB2-Jul-02 8:10 
Generalbitmap writing problem Pin
SilentWarrior2-Jul-02 6:55
SilentWarrior2-Jul-02 6:55 
hi .. ive seeked the hlp before and i got a response but still after making those changes im not able to save the bitmap file.)
here is the code which im writing .plz tell me where im doing wrong.Or plz snd me the correct code for dat
thanks


void COpenbitmapDlg::OnButtonBmp()
{
// TODO: Add your control notification handler code here



BOOL COpenbitmapDlg::WriteDIB(LPTSTR szFile, HANDLE hDIB)
{



//----------------------------------------
BITMAPFILEHEADER hdr ;
LPBITMAPINFOHEADER lpbi ;
if(!hDIB)
return FALSE ;
CFile file ;
if(!file.Open(szFile,CFile::modeWrite|CFile::modeCreate))
return FALSE ;
lpbi=(LPBITMAPINFOHEADER)hDIB;

int nColors = 1 << lpbi->biBitCount;


hdr.bfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"
hdr.bfSize = GlobalSize (hDIB) + sizeof( hdr );
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits = (DWORD) (sizeof( hdr ) + lpbi->biSize +
nColors * sizeof(RGBQUAD));

BYTE* pDib =(BYTE*)GlobalLock(hDIB);

file.Write( &hdr, sizeof(hdr) );

// Write the DIB header and the bits

// file.Write( lpbi, GlobalSize(hDib) );
file.Write( lpbi, GlobalUnlock(pDib) );


return TRUE;


}
////////////////////////////////
// calling the above function here

CString m_sBitmap ;
CClientDC dc(this);
static char BASED_CODE szFilter[] = "Bitmap Files (*.bmp)|*.bmp|JPEG Files *.jpeg";
// Create the File Open dialog

CFileDialog m_ldFile(TRUE, ".bmp", m_sBitmap,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);

// Show the File Open dialog and capture the result
if (m_ldFile.DoModal() == IDOK)
{
// Get the filename selected

m_sBitmap = m_ldFile.GetPathName();
// Load the selected bitmap file

//MessageBox(m_sBitmap);

HBITMAP hBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
m_sBitmap, IMAGE_BITMAP, 0, 0,

LR_LOADFROMFILE | LR_CREATEDIBSECTION);

// Do we have a valid handle for the loaded image?
if (hBitmap)
{ CBitmap m_bmpBitmap;
m_bmpBitmap.Attach(hBitmap);
BITMAP bmp;
m_bmpBitmap.GetBitmap(&bmp);

CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
dcMem.SelectObject(&m_bmpBitmap);
dc.BitBlt(0,0,bmp.bmWidth,bmp.bmHeight,&dcMem,0,0,SRCCOPY);

WriteDIB("C:\\1.BMP",hBitmap);


}



}


}



looking forward from all the gurus of code
GeneralRe: bitmap writing problem Pin
Davide Pizzolato2-Jul-02 7:07
Davide Pizzolato2-Jul-02 7:07 
GeneralRe: bitmap writing problem Pin
Speedy3-Jul-02 11:04
Speedy3-Jul-02 11:04 
GeneralPreallocate a map Pin
2-Jul-02 6:49
suss2-Jul-02 6:49 
GeneralRe: Preallocate a map Pin
Joaquín M López Muñoz2-Jul-02 11:01
Joaquín M López Muñoz2-Jul-02 11:01 
GeneralRe: Preallocate a map Pin
markkuk2-Jul-02 21:23
markkuk2-Jul-02 21:23 
GeneralRe: Preallocate a map Pin
Alexandru Savescu2-Jul-02 22:49
Alexandru Savescu2-Jul-02 22:49 
Generalview2 will not show when selected from file/new Pin
ns2-Jul-02 6:02
ns2-Jul-02 6:02 
GeneralAssigning a member variable... Pin
RuiSantiago2-Jul-02 5:53
RuiSantiago2-Jul-02 5:53 
GeneralRe: Assigning a member variable... Pin
RuiSantiago2-Jul-02 6:14
RuiSantiago2-Jul-02 6:14 
GeneralClass Wizard Visual C++ 6.0 (DAO) can not recognize MS Access 2000 format Pin
2-Jul-02 5:28
suss2-Jul-02 5:28 
GeneralRe: Class Wizard Visual C++ 6.0 (DAO) can not recognize MS Access 2000 format Pin
#realJSOP2-Jul-02 6:27
professional#realJSOP2-Jul-02 6:27 
Generalreceiving messages in mdi Pin
ns2-Jul-02 5:27
ns2-Jul-02 5:27 
GeneralRe: receiving messages in mdi Pin
Mike Nordell2-Jul-02 8:01
Mike Nordell2-Jul-02 8:01 
GeneralNewbie to Direct3D question Pin
Joel Holdsworth2-Jul-02 5:24
Joel Holdsworth2-Jul-02 5:24 
GeneralRe: Newbie to Direct3D question Pin
Mike Nordell2-Jul-02 8:05
Mike Nordell2-Jul-02 8:05 
Generalanother mdi question Pin
ns2-Jul-02 5:09
ns2-Jul-02 5:09 

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.