gtkのライブラリを使うと簡単にjpgからbmpを作れる!

なんとなく作ってみました。
jpgからbmpコンバーター

こんな感じのコードに

/**
 * How to compile
 * g++ main.cpp  `pkg-config gtk+-2.0 --cflags --libs`
 */
//	Pre porcessor
#include 
#include 
#include 
using namespace std;

// alias
typedef unsigned short WORD;
typedef unsigned char BYTE;
typedef unsigned long DWORD;
typedef unsigned long LONG;

// define class & struct
typedef struct tagBITMAPFILEHEADER {
        WORD    bfType;
        DWORD   bfSize;
        WORD    bfReserved1;
        WORD    bfReserved2;
        DWORD   bfOffBits;
} BITMAPFILEHEADER, *LPBITMAPFILEHEADER, *PBITMAPFILEHEADER;

typedef struct tagBITMAPINFOHEADER{
        DWORD      biSize;//!< BITMAPINFOHEADER's size
        LONG       biWidth;//!< image's width
        LONG       biHeight;//!< image's height
        WORD       biPlanes;//!< a number of plane(always 1)
        WORD       biBitCount;//!< bits per 1 Pixel( 0 1 4 8 16 24 32)
        DWORD      biCompression;//!bmiHeader.biHeight * info->bmiHeader.biWidth * sizeof( unsigned int ) );
  WORD    bfReserved1 = 0;
  WORD    bfReserved2 = 0;
  DWORD   bfOffBits = 14 + sizeof( BITMAPINFO ); // offset to pixel data
  
  fwrite( bfType, sizeof(char), 2, fp);
  fwrite( &bfSize, sizeof(DWORD), 1, fp);
  fwrite( &bfReserved1, sizeof(WORD), 1, fp);
  fwrite( &bfReserved2, sizeof(WORD), 1, fp);
  fwrite( &bfOffBits, sizeof(DWORD), 1, fp);
  
  fwrite( info, sizeof( BITMAPINFO ) , 1, fp);
  fwrite( pixel, sizeof( unsigned int ), info->bmiHeader.biHeight * info->bmiHeader.biWidth, fp);
  
  fclose(fp);
}


int main(int argc, char* argv)
{
  GdkPixbuf* pixbuf = NULL;
  gtk_init(&argc, &argv);

  if( argc > 1 ){
	GError* error = NULL;
	pixbuf = gdk_pixbuf_new_from_file(argv[1],
												 &error);
	if( pixbuf == NULL ){
	  cout << "error->code:" << error->code << endl;
	  cout << "error->message:" << error->message << endl;
	  return 1;
	}
  }

  // display infomations of jpg 
  cout << "width = " << gdk_pixbuf_get_width(pixbuf) << endl;
  cout << "height = " << gdk_pixbuf_get_height(pixbuf) << endl;
  cout << "bits per sample = " << gdk_pixbuf_get_bits_per_sample(pixbuf)< pixeldata;

  if( pixbuf != NULL ) g_object_unref(pixbuf);
  return 0;
}