Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Image.GetType method

Applies to: desktop apps only

The Image::GetType method gets the type (bitmap or metafile) of this Image object.

Syntax

ImageType GetType();

Parameters

This method has no parameters.

Return value

Type:

Type: ImageType

This method returns an element of the ImageType enumeration that indicates the image type.

Examples

The following example creates two Image objects: one based on a JPEG file and one based on an EMF file. The code calls the Image::GetType method of each Image object. Then the code verifies that the JPEG file is a bitmap and the EMF file is a metafile.


#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

INT main()
{
   GdiplusStartupInput gdiplusStartupInput;
   ULONG_PTR gdiplusToken;
   GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

   Image* image1 = new Image(L"FakePhoto.jpg");
   Image* image2 = new Image(L"SampleMetafile.emf");

   ImageType type1 = image1->GetType();
   ImageType type2 = image2->GetType();

   if(type1 == ImageTypeBitmap)
      printf("The type of image1 is ImageTypeBitmap.\n");

   if(type2 == ImageTypeMetafile)
      printf("The type of image2 is ImageTypeMetafile.\n");

   delete image1;
   delete image2;
   GdiplusShutdown(gdiplusToken);
   return 0;
}

The preceding code, along with two particular files, FakePhoto.jpg and SampleMetafile.emf, produced the following output:


The type of image1 is ImageTypeBitmap.
The type of image2 is ImageTypeMetafile.

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
ImageType
Loading and Displaying Metafiles
Types of Bitmaps

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

Show: