IExtractImage thumbnail shell extensions RRS feed

  • Question


    I'm working on a thumbnail extractor shell extension for a custom file type (Windows XP only, i.e., we don't have Vista boxes and can't use the new thumbnail providers).  For testing, I've registered an extension for a bogus file type and created a file with that type, but the prototype will actually pull the bitmap from a paint .bmp file in the same folder.  The basic mechanism in my prototype seems to work OK, except that the test thumbnail that I extract from the .bmp file and that the shell displays appears to be somewhat lower resolution than the thumbnail that the .bmp file type's own thumbnail extractor gets from the same file.  In theory, the thumbnail for my bogus file type should look the same as the thrumbnail produced by the .bmp file since it's actually pulling the bitmap from the same file.  (Or maybe the paint .bmp file has cached or processes a spiffier thumbnail image somehow?)  My extractor prototype appears to produce a thumbnail of the correct size and same scale, and has the same colors, but it appears somewhat "coarser" or "splotchier" than the thumbnail the shell produces for the .bmp.


    I can't find a really straightforward example of doing shell extension thumbnail extractors from an actual bitmap (pre-Vista) anywhere .  (The only complete example I've found is on CodeProject for the scribble example, but it's bound up with reusing the wrapped GDI objects from the MFC doc/view implementation of the original app.  The only examples I've found on MSDN are a couple of Dino Esposito's shell extension articles from (way) back issues of MSDN Magazine, and in the very simple thumbnail examples he gave to illustrate the facility, he just grabbed an existing icon.)


    I've pieced the following code together from various sources.  Oddly, and maybe this is a clue, I get the same thumbnail image result if I just Detach() the bitmap from the CImage and don't even attempt the scaling.  (Uses Visual Studio 2008 ATL.  The m_bmSize width/height member is stored from the preceding IExtractImage GetLocation call's 'const SIZE *prgSize' parameter which is supposed to suggest the size.)


    STDMETHODIMP CmyThumbGetter::Extract(HBITMAP* phBmpThumbnail)


    CImage ciTheImage;

    ciTheImage.Load(_T("C:\\Documents and Settings\\xyzzy\My Documents\\Visual Studio 2008\\Projects\\myThumbProto2\\myThumbProto2\\myimg.bmp"));

    HDC hmemDC = CreateCompatibleDC(NULL);

    SetStretchBltMode(hmemDC, HALFTONE);

    SetBrushOrgEx (hmemDC, 0, 0, NULL);

    HBITMAP hmemBM = CreateCompatibleBitmap (hmemDC, m_bmSize.cx, m_bmSize.cy );

    SelectObject (hmemDC, hmemBM);

    ciTheImage.StretchBlt(hmemDC, 0, 0, m_bmSize.cx, m_bmSize.cy, HALFTONE);

    *phBmpThumbnail = ciTheImage.Detach();

    ReleaseDC(NULL, hmemDC);


    return NOERROR;






    Wednesday, March 26, 2008 11:01 PM


  • Dear linearred,


    Thanks for participating on the MSDN Forum, but this forum section is reserved for Visual C++ General Questions. For IExtractImage question, you can post your question on the platformsdk.shell newsgroup, there you find IExtractImage experts and your question should be answered in no time.

    The people there will have enough experience with IExtractImage to give you the best advice or answer!




    Tuesday, April 1, 2008 11:18 AM