All pastes #212104 Raw Edit

Something

public text v1 · immutable
#212104 ·published 2006-10-20 18:15 UTC
rendered paste body
  #include <stdio.h>
#include <gdip.h>
#include <pngcodec.h>

#define CHECK_STATUS(x) do { if (status != Ok) { printf ("status[%d] == %d!\n", status_counter++, status); if(x) { exit(-1); } } else { printf ("status[%d] == Ok\n", status_counter++); } } while (0)



int main ( int argc, char ** argv )
{
  unsigned long gdiplusToken;
  GdiplusStartup(&gdiplusToken, NULL, NULL);

  int width, height ;
  int status_counter=0;

  int a,r,g,b ;

  cairo_surface_t * surface ;
  cairo_status_t cairo_status ;
  GpGraphics * graphics ;
  GpBitmap * image ;
  GpPen * pen ;
  GpStatus status ;

  FILE * fileout ;

  width=200;
  height=200;

  a=255 ;
  r=255;
  g=0;
  b=0;
  GpBitmap *bitmap;^M
  status =  GdipCreateBitmapFromScan0(200, 200, 0, Format32bppArgb, 0, &bitmap);
  CHECK_STATUS(1);

  GpRect rect;
  rect.X = 0;
  rect.Y = 0;
  rect.Width = 200;
  rect.Height = 200;

  status =  GdipGetImageGraphicsContext(bitmap, &graphics);
  CHECK_STATUS(1);
  status =  GdipSetVisibleClip_linux (graphics, &rect);
  CHECK_STATUS(1);


  status = GdipCreatePen1 ( 0x00FF00FF, 5 , UnitPixel , &pen ) ;
  CHECK_STATUS(1);

  status = GdipDrawLine ( graphics , pen , 0 , 0 , 100 , 100 ) ;
  CHECK_STATUS(1);

  WCHAR file[] = {'t', 'e', 's', 't', '.', 'p', 'n', 'g', 0};
  UINT numEncoders, size, cnt;
  ImageCodecInfo *encoders, *encoder;

  GdipGetImageEncodersSize (&numEncoders, &size);

  if (numEncoders == 0) {
    fprintf ( stdout , "numEncoders == 0\n" ) ;
  
  encoders = GdipAlloc (size);

  GdipGetImageEncoders (numEncoders, size, encoders);

  status = GdipSaveImageToFile (bitmap, file, &(encoders[1]).Clsid, 0);
  CHECK_STATUS(1);

  GdipFree (encoders);

  GdiplusShutdown(gdiplusToken);

  return 0;
}