CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    111

    Gdiplus::Image:FromFile holds the file

    I use GDI+ for displaying an image file.

    1. Getting m_pImg = Gdiplus::Image::FromFile( m_fileName ); on browse button click
    2. And drawing the image in OnDraw()
    m_pGr->DrawImage( m_pImg, destX, destY, destWidth, destHeight);
    ( where m_pGr is Gdiplus :: Graphics )

    When I checked I found that after calling FromFile the file is not release by the application untill I close the application.

    So that when I tried CFile::Open( ) for the file, GetLasterror returned 32(The process cannot access the file because it is being used by another process. )

    Could you please help me hoe can I get rid of this situation.
    Is FromFile really holds the file? If so please suggest a good way to display the image.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Gdiplus::Image:FromFile holds the file

    I've not used Gdiplus::Image before.

    It seems that the Image class keeps a hold of the file until it is done. This is probably because the Image class can be modified, and the modifications saved. Seems pretty inflexible to me since Gdiplus doesn't have many (any?) other way to display an image.

    You can open the file if you use the CFile::shareDenyNone flag. Why do you need to open the file?

    Also, the MFC class CImage is probably more flexible in your case.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured