 |
|
 |
The code for dialog box:
void cLiveJPEG::OnPaint() {
CPaintDC dc(this); // device context for painting CRect rect; GetDlgItem(IDC_STATIC_MJPEGWIN)->GetClientRect(&rect); CWnd *pWnd = (CWnd*)GetDlgItem(IDC_STATIC_MJPEGWIN); if (pWnd){ CDC *pDC = pWnd->GetDC(); CMemDC cDC(pDC);
m_cPict->Show(&cDC, rect); }
}
#ifndef _MEMDC_H_ #define _MEMDC_H_
////////////////////////////////////////////////// // CMemDC - memory DC // // Author: Keith Rule // Email: keithr@europa.com // Copyright 1996-1999, Keith Rule // // You may freely use or modify this code provided this // Copyright is included in all derived versions. // // History - 10/3/97 Fixed scrolling bug. // Added print support. - KR // // 11/3/99 Fixed most common complaint. Added // background color fill. - KR // // 11/3/99 Added support for mapping modes other than // MM_TEXT as suggested by Lee Sang Hun. - KR // // This class implements a memory Device Context which allows // flicker free drawing.
class CMemDC : public CDC { private: CBitmap m_bitmap; // Offscreen bitmap CBitmap* m_oldBitmap; // bitmap originally found in CMemDC CDC* m_pDC; // Saves CDC passed in constructor CRect m_rect; // Rectangle of drawing area. BOOL m_bMemDC; // TRUE if CDC really is a Memory DC. public: CMemDC(CDC* pDC, const CRect* pRect = NULL) : CDC() { ASSERT(pDC != NULL);
// Some initialization m_pDC = pDC; m_oldBitmap = NULL; m_bMemDC = !pDC->IsPrinting();
// Get the rectangle to draw if (pRect == NULL) { pDC->GetClipBox(&m_rect); } else { m_rect = *pRect; } if (m_bMemDC) { // Create a Memory DC CreateCompatibleDC(pDC); pDC->LPtoDP(&m_rect);
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height()); m_oldBitmap = SelectObject(&m_bitmap); SetMapMode(pDC->GetMapMode()); pDC->DPtoLP(&m_rect); SetWindowOrg(m_rect.left, m_rect.top); } else { // Make a copy of the relevent parts of the current DC for printing m_bPrinting = pDC->m_bPrinting; m_hDC = pDC->m_hDC; m_hAttribDC = pDC->m_hAttribDC; }
// Fill background FillSolidRect(m_rect, pDC->GetBkColor()); }
~CMemDC() { if (m_bMemDC) { // Copy the offscreen bitmap onto the screen. m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), this, m_rect.left, m_rect.top, SRCCOPY); //Swap back the original bitmap. SelectObject(m_oldBitmap); } else { // All we need to do is replace the DC with an illegal value, // this keeps us from accidently deleting the handles associated with // the CDC that was passed to the constructor. m_hDC = m_hAttribDC = NULL; } } // Allow usage as a pointer CMemDC* operator->() { return this; }
// Allow usage as a pointer operator CMemDC*() { return this; } };
#endif
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
In MS PowerPoint, Big picture(4MB Jpg) can be rotated really fast. I was wondering if PowerPoint is using IPicture. Anybody please give me a clue?
Hu
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Useful.
Demian.
"I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
Thanks you for CPicture class, I derived it from CStatic and now I can place a CStatic image in my dialog resource editor to put the final place and size of the image, borders, ..., it help me a lot of.
Bye.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
I want to put image to IDC_STATIC control. How do I use it ? This is my code below, but it display nothing.:(
bool bGetBitmap = false; OnPaint() { if (bGetBitmap) { CStatic *pStaic; pStaic=(CStatic*)GetDlgItem(IDC_STATIC_BITMAP); CDC *pDc;
pDc = pStaic->GetDC(); CRect ClientArea; pStaic->GetWindowRect(&ClientArea); m_Picture.UpdateSizeOnDC(pDc); m_Picture.Show(pDc,CRect(0,0,ClientArea.Width(),ClientArea.Height())); } }
OnButton1() { bGetBitmap = true; m_Picture.Load("C:\\123.bmp"); Invalidate(); }
|
| Sign In·View Thread·PermaLink | 1.33/5 (2 votes) |
|
|
|
 |
|
 |
I would rather derivate a class from CStatic, catch the WM_PAINT message and there process the drawing using m_Picture.
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
 |
do like this :
CRect m_ClientRect; m_ctlFOTO.GetClientRect(&m_ClientRect); m_Picture.Show(m_ctlFOTO.GetWindowDC(), m_ClientRect);
***
m_ctlFOTO is a control variable for the static container
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I am using these great classes to display images with Visual C++ .Net. The only thing is when I load a big image, I would need some scrollbar on the side to be able to look at the entire picture, do anyone would know how to do that ?
Thanks
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
 |
Hi, I am looking for a way to obtain the pixels value of the loaded image, do you have any idea ? Thanks a lot !
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The slow way is the GetPixel method, the fast way is to load your image into a DIBSection and traverse the bits.
Christian Graus - Microsoft MVP - C++
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
It too searching the way to load different image format from the RESOURCE.
thanks
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Add this member function to class CPicture.
// Caller should call ::DeletecObject(hbitmap_got) later. HBITMAP CPicture::GetBitmap(CDC* pDC) { HBITMAP hbitmap = NULL;
if(m_pPicture != NULL) { CSize size = GetSize(pDC); HDC hdc = ::CreateCompatibleDC(pDC->GetSafeHdc()); if(hdc) { hbitmap = ::CreateCompatibleBitmap(hdc, size.cx, size.cy); if(hbitmap) { HBITMAP hbitmapOld = (HBITMAP) ::SelectObject(hdc, hbitmap); Draw( CDC::FromHandle(hdc) ); ::SelectObject(hdc, hbitmapOld); } ::DeleteDC(hdc); } }
return hbitmap; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
naragana wrote: Add this member function to class CPicture.
What about this code
BOOL CPicture::GetBitmap(CBitmap *retBitmap) {
//check is we got IPicture Interface if(!m_IPicture) return FALSE;
//Now retrieve HANDLE of currently selected bitmap OLE_HANDLE hPic; m_IPicture->get_Handle(&hPic); retBitmap=CBitmap::FromHandle((HBITMAP)hPic);
return TRUE;
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I got a runtime error when the program was executing the CPictureShowDoc::CreateFilesList function. there is a missing call to m_Finder.FindNextFile() Here is the correct code:
BOOL CPictureShowDoc::CreateFilesList() //============================================================================= { m_Finding = m_Finder.FindFile("*.*"); // Finds All Files (By Name)
m_Finder.FindNextFile(); The missing line
CString Extention; ... ... Besides the code works perfectly Thanks

|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hi, i am computer engineering student. i have to build a basic graphics editor similar to paint as part of my project. i would like to know how i could save the images created with the editor in jpg or gif formats?
i am using bc++ 5.03 and the Dev c++ compilers
thanks...
please do mail me a copy of your response to captain_napalm@hotmail.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
How can I change pictures in my Dialog, show different pictures? For example, by pressing button OK.
|
| Sign In·View Thread·PermaLink | 1.67/5 (6 votes) |
|
|
|
 |
|
 |
Any idea, how can I ROTATE 90, 180 etc using an IPicture object, once it is loaded and showing on screen...
Thanks Alex
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Alow,
Usually i extract all the information from the loaded picture into a dib files. Than the extracted information i put in 2 dimension matrix. Having that matrix containing all the data, i will make calculation about matrix transformation to rotate it, inverse or anything
hope this will help cheers,
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
When I call the CPicture::Load function and pass in as the file name an image from an ftp site if fails to open the image. What do I have to do inorder to allow for the opening of an image from an ftp site?
Thanks for your help
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
i am doing a project in vc++, that is "Automated attendency system using Fingerprints".the storage of fingerprints bitmap images in database is taking more space ,so i want to need help of compression images and store that in database.
K.kranthi kumar
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
 Hi, I wanna ask about getting raw image data pixel by pixel, such as a matrix, no no exactly as a matrix. I wanna process image data.
Thanx for help...
(if u can, please quick, i'm in hurry )
GORGULUS
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
 |
how to save the bitmap image into jpeg image. thanks in advance
----------------------------- "I Think It will Work" Formerly Known As "Alok The Programmer" at CP ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Found here: http://desktop.google.com/framework.html
// Do the conversion from a HBITMAP to IPicture PICTDESC picture_desc; picture_desc.cbSizeofstruct = sizeof(picture_desc); picture_desc.picType = PICTYPE_BITMAP; picture_desc.bmp.hbitmap = bitmap; picture_desc.bmp.hpal = NULL; HRESULT hr = OleCreatePictureIndirect(&picture_desc, IID_IPicture, TRUE, (void**)&tile_icon); if (FAILED(hr)) return E_FAIL;
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |