How to copy from CBitmap to CBitmap
-
I have two objects: CBitmap bmp1, CBitmap bmp2. There is a sample picture in the bmp1 and the same picture in the bmp2. Now, I get a copy of the part bmp1 and put it to the CBitmap bmp3. But I don't want to create another CBitmap object. I want release bmp2 interior and put there the new part of the picture wchich is in the bmp3. How can I do it. I can't do bmp2 = bmp3, there is no function like: bmp2.Assign(bmp3). What can I do? Regards mwgomez Poland
-
I have two objects: CBitmap bmp1, CBitmap bmp2. There is a sample picture in the bmp1 and the same picture in the bmp2. Now, I get a copy of the part bmp1 and put it to the CBitmap bmp3. But I don't want to create another CBitmap object. I want release bmp2 interior and put there the new part of the picture wchich is in the bmp3. How can I do it. I can't do bmp2 = bmp3, there is no function like: bmp2.Assign(bmp3). What can I do? Regards mwgomez Poland
-
I have two objects: CBitmap bmp1, CBitmap bmp2. There is a sample picture in the bmp1 and the same picture in the bmp2. Now, I get a copy of the part bmp1 and put it to the CBitmap bmp3. But I don't want to create another CBitmap object. I want release bmp2 interior and put there the new part of the picture wchich is in the bmp3. How can I do it. I can't do bmp2 = bmp3, there is no function like: bmp2.Assign(bmp3). What can I do? Regards mwgomez Poland
gomez_a wrote:
CBitmap bmp1, CBitmap bmp2
what about CBitmap* PASCAL FromHandle( HBITMAP hBitmap)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
V_shr wrote:
bmp2->Canvas->Draw(0,0,bmp3);
Where is Canvas variable Situated?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
V_shr wrote:
bmp2->Canvas->Draw(0,0,bmp3);
Where is Canvas variable Situated?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
V_shr wrote:
bmp2->Canvas->Draw(0,0,bmp3);
Where is Canvas variable Situated?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
Hi ThatsAlok, maybe in future:-D_**
**_
whitesky
-
gomez_a wrote:
CBitmap bmp1, CBitmap bmp2
what about CBitmap* PASCAL FromHandle( HBITMAP hBitmap)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
Please, give me a suggest: How can I get a HBITMAP, when I have only CBitmap bmp3? I found an example: HBITMAP hBitmap = (HBITMAP) ::LoadImage (NULL, lpszPathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); But, my bmp3 is not from a file. Regards mwgomez
-
Please, give me a suggest: How can I get a HBITMAP, when I have only CBitmap bmp3? I found an example: HBITMAP hBitmap = (HBITMAP) ::LoadImage (NULL, lpszPathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); But, my bmp3 is not from a file. Regards mwgomez
if you have CBitmap you can use bmp3.m_hObject_**
**_
whitesky
-
if you have CBitmap you can use bmp3.m_hObject_**
**_
whitesky
I wrote a class in MFC (MyClass : public CWnd), in this class I have a field CBitmap mBitmap; // not a pointer I set the bitmap using method: SetBitmap(UINT nIDResource) { return m_Bitmap.LoadBitmap(nIDResource); } But now I want to set the bitmap using: SetBitmap(CBitmap *pBitmap); I don't know how to assign (change?) CBitmap *pBitmap to CBitmap mBitmap. This is only a practice, but I want to understand it. Regards
-
Please, give me a suggest: How can I get a HBITMAP, when I have only CBitmap bmp3? I found an example: HBITMAP hBitmap = (HBITMAP) ::LoadImage (NULL, lpszPathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); But, my bmp3 is not from a file. Regards mwgomez
gomez_a wrote:
How can I get a HBITMAP, when I have only CBitmap bmp3?
CBitmap::operator HBITMAP
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
V_shr wrote:
do you mean Graphics::TBitmap ???
I believe Poster is refering to MFC:: CBitmap (Though MFC is not a namespace)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
Hi ThatsAlok, maybe in future:-D_**
**_
whitesky
WhiteSky wrote:
maybe in future:-D
I believe in 2106 when our ancestor are codingĀ (oops thinking):)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
WhiteSky wrote:
maybe in future:-D
I believe in 2106 when our ancestor are codingĀ (oops thinking):)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
2106 but one question why 2106_**
**_
whitesky
-
I wrote a class in MFC (MyClass : public CWnd), in this class I have a field CBitmap mBitmap; // not a pointer I set the bitmap using method: SetBitmap(UINT nIDResource) { return m_Bitmap.LoadBitmap(nIDResource); } But now I want to set the bitmap using: SetBitmap(CBitmap *pBitmap); I don't know how to assign (change?) CBitmap *pBitmap to CBitmap mBitmap. This is only a practice, but I want to understand it. Regards
I dont understand you have one function SetBitmap(UINT nIDResource) now you want to pass SetBitmap(CBitmap *pBitmap); to this function or your problem CBitmap mBitmap_**
**_
whitesky
-
I dont understand you have one function SetBitmap(UINT nIDResource) now you want to pass SetBitmap(CBitmap *pBitmap); to this function or your problem CBitmap mBitmap_**
**_
whitesky
Suppose we have a class: class CBitmapViewer : public CWnd { ... public: CBitmap m_Bitmap; // the BMP is loaded here CRect R; // the whole window size public: virtual BOOL Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle = WS_VISIBLE); BOOL SetBitmap(UINT nIDResource); }; I am creating the picture 1: CRect RPicture1(10, 10, 200, 200); mPicture1 = new CBitmapViewer(); mPicture1->Create(this, RPicture1, ID_OBRAZEK); mPicture1->SetBitmap(IDB_BITMAP_CHILD); I am creating the picture 2: CRect RPicture2(10, 220, 200, 410); mPicture2 = new CBitmapViewer(); mPicture2->Create(this, RPicture2, ID_OBRAZEK); mPicture2->SetBitmap(IDB_BITMAP_CHILD); There are two picture on the screen. Now the user can mark the part of the first window. This coorinates are placed in CRect Rf. Now, I am cutting down a part of the picture one - using the Rf coordinates: int mWidth = Rf.Width(); int mHeight = Rf.Height(); CBitmap bmp_part; bmp_part.CreateBitmap(mWidth, mHeight, 1, 24, NULL); // get the bitmap size BITMAP bitmap_size; bmp_part.GetObject(sizeof(BITMAP), &bitmap_size); // get a bitmap's part from Picture1 and place them into the bmp_part unsigned char *pData2 = new unsigned char[bitmap_size.bmHeight * bitmap_size.bmWidthBytes]; mPicture1->m_Bitmap.GetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2); bmp_part.SetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2); delete[] pData2; /* when I have a part of the Picture1 in the bmp_part a want to replace a Picture2 with bmp_part. */ For example using: mPicture2.Assign(&bmp_part); or I can to create the new object: mNewBitmap = new CBitmapViewer(); mNewBitmap->Create(this, R3, ID_OBRAZEK3); // CRect R3 - where the window is placed mNewBitmap->AssignBitmap(&bmp_part); From this moment I want some help, becouse I don't know how to do it Regards
-
Suppose we have a class: class CBitmapViewer : public CWnd { ... public: CBitmap m_Bitmap; // the BMP is loaded here CRect R; // the whole window size public: virtual BOOL Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle = WS_VISIBLE); BOOL SetBitmap(UINT nIDResource); }; I am creating the picture 1: CRect RPicture1(10, 10, 200, 200); mPicture1 = new CBitmapViewer(); mPicture1->Create(this, RPicture1, ID_OBRAZEK); mPicture1->SetBitmap(IDB_BITMAP_CHILD); I am creating the picture 2: CRect RPicture2(10, 220, 200, 410); mPicture2 = new CBitmapViewer(); mPicture2->Create(this, RPicture2, ID_OBRAZEK); mPicture2->SetBitmap(IDB_BITMAP_CHILD); There are two picture on the screen. Now the user can mark the part of the first window. This coorinates are placed in CRect Rf. Now, I am cutting down a part of the picture one - using the Rf coordinates: int mWidth = Rf.Width(); int mHeight = Rf.Height(); CBitmap bmp_part; bmp_part.CreateBitmap(mWidth, mHeight, 1, 24, NULL); // get the bitmap size BITMAP bitmap_size; bmp_part.GetObject(sizeof(BITMAP), &bitmap_size); // get a bitmap's part from Picture1 and place them into the bmp_part unsigned char *pData2 = new unsigned char[bitmap_size.bmHeight * bitmap_size.bmWidthBytes]; mPicture1->m_Bitmap.GetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2); bmp_part.SetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2); delete[] pData2; /* when I have a part of the Picture1 in the bmp_part a want to replace a Picture2 with bmp_part. */ For example using: mPicture2.Assign(&bmp_part); or I can to create the new object: mNewBitmap = new CBitmapViewer(); mNewBitmap->Create(this, R3, ID_OBRAZEK3); // CRect R3 - where the window is placed mNewBitmap->AssignBitmap(&bmp_part); From this moment I want some help, becouse I don't know how to do it Regards
Hope I understood your question
void CAnswerDlg::OnBnClickedTest() { CBitmapViewer *mNewBitmap; CBitmap bmp_part; bmp_part.Attach((HBITMAP)LoadImage(AfxGetInstanceHandle(),"c:\\0.bmp",IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION)); CRect R3; mNewBitmap = new CBitmapViewer(); mNewBitmap->Create(this, R3, 1); // CRect R3 - where the window is placed mNewBitmap->SetBitmap2(&bmp_part); mNewBitmap->DestroyWindow(); /* if you use this code you see one file CImage m; m.Attach(mNewBitmap->m_Bitmap); m.Save("c:\\test.bmp"); m.Detach();*/ } BOOL CBitmapViewer::Create(CWnd* pParentWnd, const RECT& rect,UINT nID,DWORD dwStyle) { return CWnd::Create("CBitmapViewer","",dwStyle,rect,pParentWnd,1,0); } BOOL CBitmapViewer::SetBitmap(UINT nIDResource) { return m_Bitmap.LoadBitmap(nIDResource); } void CBitmapViewer::SetBitmap2(CBitmap *m) { m_Bitmap.Attach((HBITMAP)m->m_hObject); }
_**
**_
whitesky