The GDI+

Environment: [VC6 SP4, NT4 SP3, W2k, Win 9x]

I have found that the Microsft GDI+ can do many cool things for you. Previously you had to find code or write your own code to do the same things. One of these things is the ability to load or save the following types of images:

  • BMP
  • DIB
  • RLE
  • GIF
  • JPEG
  • EMF
  • TIFF
  • PNG

These can be loaded with just a few lines of code like this:

#include <Gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")

Image Im(L"c:\\fig.jpg", FALSE);
CLSID GifCodec;
GetCodecClsid(L"image/gif", &GifCodec);
Im.Save(L"c:\\fig.gif", &GifCodec, NULL);

Here is the code to GetCodecClsid
int GetCodecClsid(const WCHAR* format, CLSID* pClsid)
  UINT num = 0;  // number of image encoders
  UINT size = 0; // size of the image encoder array in bytes

  ImageCodecInfo* pImageCodecInfo = NULL;

  GetImageEncodersSize(&num, &size);
  if(size == 0)
    return -1; // Failure

  pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
  if(pImageCodecInfo == NULL)
    return -1; // Failure
  GetImageEncoders(num, size, pImageCodecInfo);

  for(UINT j = 0; j < num; ++j)
     if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
       *pClsid = pImageCodecInfo[j].Clsid;
       return j; // Success
  } // for

  return -1; // Failure
} // GetCodecClsid

All help about GDI+ can be found at:


Here is the library, headers and the dll to build the samples (900K):


  • NABGU jPc tnMF

    Posted by MFCNYoNRux on 11/13/2012 06:30pm

    buy soma online carisoprodol can you snort - carisoprodol drug interactions

  • Goal

    Posted by snareenactina on 11/13/2012 09:17am

    Build Bulk Cargo Handling Unit II-39 zelmenis The Finnish inventor's IndoorAtlas software uses magnetic field data to identify smartphone users' locations schmidt angiograms peakabove powerfulge admissible

  • New one

    Posted by snareenactina on 11/06/2012 04:40am

    pewclimate French literature reflects the nation’s multi-hued culture and political dynamism. Several literary movements like Dadaism, Surrealism, and Existentialism have been started and nurtured in France. Since the late 19th century, the nation has also come to be known as a sort of focal point for modern art, cinema, fashion, and cuisine. Cocteau, Dumont, and Godard are some of its celebrated film-makers, while Pierre Cardin, Chanel, Givenchy, and Louis Vuitton are iconic names in the contemporary world of fashion. Europe has only one advantage over the US and that is its ability to spend close to nothing on a military budget because the United States will defend Europe under any opposing threat. Europe’s very existence depends on US supremacy. If the US decides to become a socialist state like Europe or if China calls in our debts, China will be in position to become the next superpower. Evidence of this is the German prime minister being opposed to “Obama spending”. The real question is, does anybody here believe China, with a poor track-record of preserving human rights, will come to defend Europe from the Middle East when the US can no longer financially provide military aid? I think not. Try zooming out for a broader look. forerunner Growth and protectionism 157 suggests Some articles that match your query: scotlands Cranky, the New York Times editorial came out and rallied around Obama??? Wow, more breaking news from the Associated Press: The Pope is Catholic and the Chicago Cubs will go 112 years without winning the world series. I mean seriously Cranky. judiciaries Like the poster above me I'd like to thank you for another one of your generally excellent and insightful comments on the economy. Over the past couple of years they have probably been amongst the most accurate forecasts out there. beetles The Moitor highlights that while unemployment continues to rise, longer term propsecxts give cause fo optimism as a result of a number of major development projects being taken forward. exclusivists Source: mundane For some time now, blogs and op-eds have been circulating a common myth about ‘great recession’ hiring. Namely, high unemployment is derived from a mismatch of job applicant skills versus job position skill requirements. And the absolutely true answer is: Chronic high unemployment is definitely NOT a supply side issue.

  • Problem with linking (GDI+ + CBuilder 5)

    Posted by Legacy on 02/22/2004 12:00am

    Originally posted by: dbf

    Hello! My gdi program compiles quite good, but it after it it is linking error.


    #include <vcl.h>
    #pragma hdrstop

    #include "Unit1.h"
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    #define STRICT
    #include <Gdiplus.h>
    using std::min;
    using std::max;
    using namespace Gdiplus;

    #pragma comment(lib, "gdiplus.lib")

    TForm1 *Form1;
    __fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
    CLSID pngClsid;
    //GetEncoderClsid(L"image/png", &pngClsid);
    //image.Save(L"Mosaic2.png", &pngClsid, NULL);
    GdiplusShutdown( gdiplusToken );

    The error is "Unresolved external call GdiplusStartupInput
    Unresolved external call GdiplusShutdown " What should I do?

  • Problem getting GDI+ to work using DirectDraw & C++Builder

    Posted by Legacy on 01/28/2004 12:00am

    Originally posted by: Megan_G

    I am trying to use GDI+ for the first time in C++Builder.
    I have a DirectDrawSurface7 that I want to manipulate using GDI+. I created an HDC object that points to the surface and used it to make a graphics object. Everything compiles and links fine. I call the rotate and translate functions and my surface comes back in the same orientation as it would be if I had never called these. Here is the code.

    HDC hdc;
    HRESULT hr;

    Gdiplus::Graphics graphics(hdc);

    Has anyone run into a problem like this? Have any ideas?

  • How to load a HICON or Bitmap object in Image handle?

    Posted by Legacy on 11/21/2003 12:00am

    Originally posted by: Yan Lee

    How to load a HICON or Bitmap object in Image handle?

  • How to load a HICON or Bitmap object in Image handle?

    Posted by Legacy on 11/21/2003 12:00am

    Originally posted by: Wang Yan

    How to load a HICON or Bitmap object in Image handle?

  • How to load a HICON or Bitmap object in Image handle?

    Posted by Legacy on 11/21/2003 12:00am

    Originally posted by: Yan Lee

    How to load a HICON or Bitmap object in Image handle?

  • Alpha blending of an EMF Image

    Posted by Legacy on 11/20/2003 12:00am

    Originally posted by: khaldoun

    I want to set the alpha blending of an emf,
    I want it to be transparent.
    my code is the folowing :
    pImage = ::new Image(strDstFileName);

    ColorMatrix colorMatrix = {1.0f,0.0f,0.0f,0.0f,0.0f,
    ImageAttributes imageAtt;

    RectF destRect(0.0f, 0.0f,

    0.0f,0.0f,pImage->GetWidth(), \

    When my image is a BMP or JPEG, it works very well,
    but when I pass an EMF file it draw nothing???
    any help

  • GDIplus.lib linker error with c++ builder 6

    Posted by Legacy on 11/19/2003 12:00am

    Originally posted by: ouioui

    I make a small app to rotate a jpeg image with c++ builder but i can't compile it. I get this error :

    [Linker Error] 'C:TEST_GDI\GDIPLUS.LIB' contains invalid OMF record, type 0x21 (possibly COFF)

    Thanks for help


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date