FreeImage Library Help [SOLVED]
-
What I'm using: VS2005, MFC, and FreeImage 3.93 and the C++ wrapper class provided by the FreeImage author... I've been playing around with this most of the weekend. What I'm Doing: I have a CWnd in which I'm trying to show a slide show of images (contained in a folder on the hard drive). The list of files that can be displayed is contained in a CStringArray called
m_saFileNames
. The slide show is controlled by a couple of timer threads, one to allows the current image to be displayed for a certain length of time, and another that keeps the next image from being displayed for a certain length of time. These threads are firing their messages correctly. I've allocated a pointer for the image object (fitWinImage* m_pLastImage
) in the CWnd's constructor. Here's the function that's called that displays the image.void CSaverWnd::FadeOn()
{
TRACE("CSaverWnd::FadeOn()\n");
if (m_pLastImage)
{
CString sFileName = m_saFileNames.GetAt(m_nNextImage);
m_pLastImage->clear();
m_pLastImage->load(sFileName);
if (m_pLastImage->isValid())
{
CPaintDC dc(this);
// Scale the image so it fits on the screen and keeps aspect ratio
ScaleImg(m_pLastImage);
int nImgWidth = m_pLastImage->getWidth();
int nImgHeight = m_pLastImage->getHeight();
int imgX = (int)((m_rect.Width() - nImgWidth) * 0.5);
int imgY = (int)((m_rect.Height() - nImgHeight) * 0.5);
m_rectLastImage.SetRect(imgX, imgY, imgX+nImgWidth, imgY+nImgHeight);
m_pLastImage->draw(dc.GetSafeHdc(), m_rectLastImage);
}
}
}The problem: It shows the first image, but won't show any of the rest. I've verified that images are being loaded (the image size and name change each time this function is called), but the draw function doesn't seem to be doing anything beyond the first image. Any help? -- modified at 19:00 Sunday 8th April, 2007 Solved, but it wouldn't mean anything to anyone but me. :)
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
What I'm using: VS2005, MFC, and FreeImage 3.93 and the C++ wrapper class provided by the FreeImage author... I've been playing around with this most of the weekend. What I'm Doing: I have a CWnd in which I'm trying to show a slide show of images (contained in a folder on the hard drive). The list of files that can be displayed is contained in a CStringArray called
m_saFileNames
. The slide show is controlled by a couple of timer threads, one to allows the current image to be displayed for a certain length of time, and another that keeps the next image from being displayed for a certain length of time. These threads are firing their messages correctly. I've allocated a pointer for the image object (fitWinImage* m_pLastImage
) in the CWnd's constructor. Here's the function that's called that displays the image.void CSaverWnd::FadeOn()
{
TRACE("CSaverWnd::FadeOn()\n");
if (m_pLastImage)
{
CString sFileName = m_saFileNames.GetAt(m_nNextImage);
m_pLastImage->clear();
m_pLastImage->load(sFileName);
if (m_pLastImage->isValid())
{
CPaintDC dc(this);
// Scale the image so it fits on the screen and keeps aspect ratio
ScaleImg(m_pLastImage);
int nImgWidth = m_pLastImage->getWidth();
int nImgHeight = m_pLastImage->getHeight();
int imgX = (int)((m_rect.Width() - nImgWidth) * 0.5);
int imgY = (int)((m_rect.Height() - nImgHeight) * 0.5);
m_rectLastImage.SetRect(imgX, imgY, imgX+nImgWidth, imgY+nImgHeight);
m_pLastImage->draw(dc.GetSafeHdc(), m_rectLastImage);
}
}
}The problem: It shows the first image, but won't show any of the rest. I've verified that images are being loaded (the image size and name change each time this function is called), but the draw function doesn't seem to be doing anything beyond the first image. Any help? -- modified at 19:00 Sunday 8th April, 2007 Solved, but it wouldn't mean anything to anyone but me. :)
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
What I'm using: VS2005, MFC, and FreeImage 3.93 and the C++ wrapper class provided by the FreeImage author... I've been playing around with this most of the weekend. What I'm Doing: I have a CWnd in which I'm trying to show a slide show of images (contained in a folder on the hard drive). The list of files that can be displayed is contained in a CStringArray called
m_saFileNames
. The slide show is controlled by a couple of timer threads, one to allows the current image to be displayed for a certain length of time, and another that keeps the next image from being displayed for a certain length of time. These threads are firing their messages correctly. I've allocated a pointer for the image object (fitWinImage* m_pLastImage
) in the CWnd's constructor. Here's the function that's called that displays the image.void CSaverWnd::FadeOn()
{
TRACE("CSaverWnd::FadeOn()\n");
if (m_pLastImage)
{
CString sFileName = m_saFileNames.GetAt(m_nNextImage);
m_pLastImage->clear();
m_pLastImage->load(sFileName);
if (m_pLastImage->isValid())
{
CPaintDC dc(this);
// Scale the image so it fits on the screen and keeps aspect ratio
ScaleImg(m_pLastImage);
int nImgWidth = m_pLastImage->getWidth();
int nImgHeight = m_pLastImage->getHeight();
int imgX = (int)((m_rect.Width() - nImgWidth) * 0.5);
int imgY = (int)((m_rect.Height() - nImgHeight) * 0.5);
m_rectLastImage.SetRect(imgX, imgY, imgX+nImgWidth, imgY+nImgHeight);
m_pLastImage->draw(dc.GetSafeHdc(), m_rectLastImage);
}
}
}The problem: It shows the first image, but won't show any of the rest. I've verified that images are being loaded (the image size and name change each time this function is called), but the draw function doesn't seem to be doing anything beyond the first image. Any help? -- modified at 19:00 Sunday 8th April, 2007 Solved, but it wouldn't mean anything to anyone but me. :)
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001is void CSaverWnd::FadeOn() being called by WM_PAINT corresponding function? if not, CPaintDC dc(this); the dc get in this way will not have a valid clipping filed in screen, means using that dc couldn't paint as u wished. :-)
life is like a box of chocolate,you never know what you r going to get.
-
is void CSaverWnd::FadeOn() being called by WM_PAINT corresponding function? if not, CPaintDC dc(this); the dc get in this way will not have a valid clipping filed in screen, means using that dc couldn't paint as u wished. :-)
life is like a box of chocolate,you never know what you r going to get.
William.Wang wrote:
CSaverWnd::FadeOn() being called by WM_PAINT corresponding function?
Nope, it's called by the OnFadeOn message handler, which is triggered when the FadeOff thread sends the appropriate message back to the window. I'm writing a screen saver for myself because a) I can't find anything already written that I want to try, b) I don't really trust programs I get off the net anymore, and c) I've never written a screen saver before. The saver fades pictures and/or quotes on/off the screen. I may even write an article about it when I'm done.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001