Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Wed, 28 May 2008 22:10:26 -0700 (PDT),    group: microsoft.public.platformsdk.gdi        back       


GDI+ Image::Save() function returns InvalidParameter   
HI,
I'm developing a module to save images extracted from DICOM files as
JPEG images.
I have successfully extracted the data from DICOM and now want to save
this data as JPEG file.
For this I've written the following piece of code. Here, to my utter
despair, the Save() function fails with InvalidParameter. In fact,
even before calling the Save function, when I view  the oImage object
in quick view, the lastResult parameter is shown as InvalidParameter.

Is'nt this the correct way to create an Image object?

The call to Write function on the IStream is success and the required
number of bytes are written into the stream.
The image is a MONOCHROME2 one and is in raw pixel data form.

Could anybody tell me what I do incorrectly here? (I'm using VS 2005
on WinXP SP2.)

CoInitialize( NULL );

    CComQIPtr< IStream, &IID_IStream> pStream;
    HRESULT hr = CreateStreamOnHGlobal( 0, TRUE, &pStream );
    if( FAILED( hr ) )
        return false;

    ULONG ulWritten = 0;
    hr = pStream->Write( (const void*) szImadeData, (ULONG)Towrite,
&ulWritten );
    if( FAILED( hr ) )  //This succeeds
        return false;

    GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR           gdiplusToken;
    Status stat = GdiplusStartup(&gdiplusToken, &gdiplusStartupInput,
NULL);

    CLSID jpgClsid;
    GetEncoderClsid(L"image/jpeg", &jpgClsid);    //CLSID is retrieved
successfully

    Image oImage( pStream, TRUE );
    stat = oImage.Save( L"D:\\MyTestJPEGImage.jpg", &jpgClsid, NULL );
    if(Ok != stat )
        return FALSE;


    GdiplusShutdown(gdiplusToken);
    CoUninitialize();
date: Wed, 28 May 2008 22:10:26 -0700 (PDT)   author:   shaji

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us