Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. FreeImage Library Help [SOLVED]

FreeImage Library Help [SOLVED]

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdebuggingjsonquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    realJSOP
    wrote on last edited by
    #1

    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

    R W 2 Replies Last reply
    0
    • R realJSOP

      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

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Are the dimensions in m_rectLastImage valid after the first image is displayed? Never mind, I wasn't looking at the code carefully enough. /ravi

      This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • R realJSOP

        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

        W Offline
        W Offline
        William Wang
        wrote on last edited by
        #3

        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.

        R 1 Reply Last reply
        0
        • W William Wang

          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.

          R Offline
          R Offline
          realJSOP
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups