Share via


Image.Image(IStream*, BOOL) constructor

Applies to: desktop apps only

Creates an Image::Image object based on a stream.

Syntax

Image(
  [in]  IStream *stream,
  [in]  BOOL useEmbeddedColorManagement = FALSE
);

Parameters

stream [in]

Type: IStream*

Pointer to an IStream interface. The implementation of IStream must include the Seek, Read, and Stat methods.

useEmbeddedColorManagement [in]

Type: BOOL

Optional. BOOL value that specifies whether the new Image::Image object applies color correction according to color management information that is embedded in the stream. Embedded information can include ICC profiles, gamma values, and chromaticity information.

FALSE

Default. Specifies that color correction is enabled

TRUE

Specifies that color correction is not enabled

Examples

The following example creates two Image::Image objects. Each Image::Image object is based on a stream that is part of a compound file. For an example of creating a compound file, see Image::Save. The code calls StgOpenStorage to open the compound file and get a pointer to its IStorage interface. Then the code calls IStorage::OpenStream to get a pointer to an IStream interface that represents one of the streams in the compound file. The code constructs an Image::Image object based on that IStream pointer and then calls Graphics::DrawImage to display the image on the screen. The code uses a similar process to construct an Image::Image object based on a second stream that is part of the same compound file.

VOID Example_ImageStream(HDC hdc)
{
   Graphics graphics(hdc);

   Image* pImage1 = NULL;
   Image* pImage2 = NULL;

   IStorage* pIStorage = NULL;
   IStream* pIStream1 = NULL;
   IStream* pIStream2 = NULL;
   HRESULT hr;
   Status stat;

   // Open an existing compound file, and get a pointer 
   // to its IStorage interface.
   hr = StgOpenStorage(
      L"CompoundFile.cmp",
      NULL, 
      STGM_READ|STGM_SHARE_EXCLUSIVE, 
      NULL,
      0, 
      &pIStorage);

   if(FAILED(hr))
      goto Exit;

   // Get a pointer to the stream StreamImage1 in the compound file.
   hr = pIStorage->OpenStream(
      L"StreamImage1", 
      NULL, 
      STGM_READ|STGM_SHARE_EXCLUSIVE,
      0,
      &pIStream1);

   if(FAILED(hr))
      goto Exit;

   // Get a pointer to the stream StreamImage2 in the compound file.
   hr = pIStorage->OpenStream(
      L"StreamImage2", 
      NULL, 
      STGM_READ|STGM_SHARE_EXCLUSIVE,
      0,
      &pIStream2);

   if(FAILED(hr))
      goto Exit;

   // Construct a new Image object based on StreamImage1.
   pImage1 = new Image(pIStream1);
   stat = pImage1->GetLastStatus();  
   if(stat != Ok)
      goto Exit;

   graphics.DrawImage(pImage1, 10, 10);

   // Construct a new Image object based on StreamImage2.
   pImage2 = new Image(pIStream2);
   stat = pImage2->GetLastStatus();
   if(stat != Ok)
      goto Exit;

   graphics.DrawImage(pImage2, 200, 10);

Exit:
   if(pImage1)
      delete pImage1;
   if(pImage2)
      delete pImage2;
   if(pIStream1)
      pIStream1->Release(); 
   if(pIStream2)
      pIStream2->Release();
   if(pIStorage)
      pIStorage->Release();
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusheaders.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Image

Bitmap

Image::Clone

Image::FromFile

Image::FromStream

Image Constructors

Loading and Displaying Bitmaps

Drawing, Positioning, and Cloning Images

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012