Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to "input" an outlined character in CRichEditView? Pin
Hans Dietrich1-Mar-11 19:30
mentorHans Dietrich1-Mar-11 19:30 
GeneralRe: How to "input" an outlined character in CRichEditView? Pin
zhong_min1-Mar-11 20:33
zhong_min1-Mar-11 20:33 
Questionimbue( locale("") ) crashing Pin
ed welch1-Mar-11 12:06
ed welch1-Mar-11 12:06 
AnswerRe: imbue( locale("") ) crashing Pin
Hans Dietrich1-Mar-11 12:14
mentorHans Dietrich1-Mar-11 12:14 
GeneralRe: imbue( locale("") ) crashing Pin
ed welch1-Mar-11 12:26
ed welch1-Mar-11 12:26 
AnswerRe: imbue( locale("") ) crashing Pin
«_Superman_»1-Mar-11 16:01
professional«_Superman_»1-Mar-11 16:01 
GeneralRe: imbue( locale("") ) crashing Pin
ed welch2-Mar-11 0:07
ed welch2-Mar-11 0:07 
QuestionImage::GetThumbnailImage() issue Pin
David Crow1-Mar-11 9:07
David Crow1-Mar-11 9:07 
I'm using Image::GetThumbnailImage() to load some JPG files into an image list that is then attached to a list control. Most of the pictures display, but a few don't. Those that display, have widths that equal or exceed their heights (landscape). Those that don't display, have heights that exceed their widths (portrait), and GetThumbnailImage() does not return an error value.

I'm scaling the images down and maintaining the aspect ratio using the following code:

int nMaxPixels = 16;
  
int nOriginalWidth = bitmap.GetWidth();
int nOriginalHeight = bitmap.GetHeight();
  
double dFactor;
if (nOriginalWidth > nOriginalHeight)
    dFactor = (double) nMaxPixels / nOriginalWidth;
else
    dFactor = (double) nMaxPixels / nOriginalHeight;
  
int newWidth  = nOriginalWidth * dFactor;
int newHeight = nOriginalHeight * dFactor;


I then add to the image list and the list control using:

Bitmap *pThumbnail = (Bitmap *) bitmap.GetThumbnailImage(newWidth, newHeight);
  
HBITMAP hBMP;
pThumbnail->GetHBITMAP(Color(255, 255, 255), &hBMP);
  
CBitmap mfcBitmap;
mfcBitmap.Attach(hBMP);
  
m_imageList.Create(16, 16, ILC_COLOR32, 5, 1);

int nImage = m_imageList.Add(&mfcBitmap, RGB(255, 255, 255));
if (nImage >= 0)
    m_listCtrl.InsertItem(nImage, fileFind.GetFileTitle(), nImage);
  
mfcBitmap.Detach();
delete pThumbnail;


Another oddity worth mentioning is that sometimes CImageList::Add() will return an existing item number. I'm not sure yet if this is related or not.

If I make the following change when calling GetThumbnailImage(), all of the pictures display although the portrait ones are stretched:

Bitmap *pThumbnail = (Bitmap *) bitmap.GetThumbnailImage(max(16, newWidth), newHeight);


Thanks.

- DC

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather


AnswerRe: Image::GetThumbnailImage() issue Pin
Hans Dietrich1-Mar-11 11:26
mentorHans Dietrich1-Mar-11 11:26 
AnswerRe: Image::GetThumbnailImage() issue Pin
Niklas L1-Mar-11 11:51
Niklas L1-Mar-11 11:51 
GeneralRe: Image::GetThumbnailImage() issue Pin
David Crow2-Mar-11 2:22
David Crow2-Mar-11 2:22 
GeneralRe: Image::GetThumbnailImage() issue Pin
Niklas L2-Mar-11 5:54
Niklas L2-Mar-11 5:54 
QuestionRe: Image::GetThumbnailImage() issue [modified] Pin
David Crow2-Mar-11 6:18
David Crow2-Mar-11 6:18 
AnswerRe: Image::GetThumbnailImage() issue Pin
Niklas L2-Mar-11 8:45
Niklas L2-Mar-11 8:45 
QuestionRegistering a 64 bit DLL from a 32 bit application Pin
Rajesh R Subramanian1-Mar-11 4:31
professionalRajesh R Subramanian1-Mar-11 4:31 
AnswerRe: Registering a 64 bit DLL from a 32 bit application Pin
Richard Andrew x641-Mar-11 7:59
professionalRichard Andrew x641-Mar-11 7:59 
GeneralRe: Registering a 64 bit DLL from a 32 bit application Pin
Rajesh R Subramanian1-Mar-11 8:36
professionalRajesh R Subramanian1-Mar-11 8:36 
AnswerRe: Registering a 64 bit DLL from a 32 bit application Pin
Rajesh R Subramanian1-Mar-11 23:18
professionalRajesh R Subramanian1-Mar-11 23:18 
QuestionHow to check if a string is base64 encoded string? Pin
rahul.kulshreshtha28-Feb-11 18:06
rahul.kulshreshtha28-Feb-11 18:06 
AnswerRe: How to check if a string is base64 encoded string? Pin
Cool_Dev28-Feb-11 18:29
Cool_Dev28-Feb-11 18:29 
GeneralRe: How to check if a string is base64 encoded string? Pin
rahul.kulshreshtha28-Feb-11 20:11
rahul.kulshreshtha28-Feb-11 20:11 
AnswerRe: How to check if a string is base64 encoded string? PinPopular
Hans Dietrich28-Feb-11 18:33
mentorHans Dietrich28-Feb-11 18:33 
GeneralRe: How to check if a string is base64 encoded string? Pin
rahul.kulshreshtha28-Feb-11 20:11
rahul.kulshreshtha28-Feb-11 20:11 
GeneralRe: How to check if a string is base64 encoded string? Pin
CPallini28-Feb-11 23:15
mveCPallini28-Feb-11 23:15 
QuestionGet Volume Name From Path Pin
Richard Andrew x6428-Feb-11 17:31
professionalRichard Andrew x6428-Feb-11 17:31 

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.