Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <GdiPlusFlat.h>
- #define CHECK(x) do { if (x != 0) { fprintf(stderr, "Got %d\n", x); } } while (0)
- int
- main(int argc, char **argv)
- {
- FILE *f, *out;
- float f_width, f_height;
- int width, height, x, y, pos;
- int *data;
- BYTE *scan0;
- GpStatus st;
- GpImage *img;
- GpBitmap *bitmap;
- GpGraphics *graphics;
- GpRect rect;
- BitmapData bmpdata;
- if (argc != 3) {
- return 1;
- }
- if (!(f = fopen(argv[1], "r"))) {
- return 1;
- }
- st = gdip_load_emf_image_from_file(f, &img);
- fprintf(stderr, "status = %d, %s\n", st, argv[1]);
- if (st == 0) {
- fprintf(stderr, "Loaded.\n");
- CHECK(GdipGetImageDimension(img, &f_width, &f_height));
- fprintf(stderr, "%f %f\n", f_width, f_height);
- /* XXX Scale down image. */
- width = f_width * 0.01;
- height = f_height * 0.01;
- scan0 = GdipAlloc(width * height * 4);
- CHECK(GdipCreateBitmapFromScan0(width, height, width * 4,
- PixelFormat32bppARGB, scan0, &bitmap));
- CHECK(GdipGetImageGraphicsContext(bitmap, &graphics));
- if (!GdipDrawImageRect(graphics, img, 0, 0, (float)width, (float)height)) {
- if (!(out = fopen(argv[2], "wb"))) {
- return 1;
- }
- CHECK(gdip_save_bmp_image_to_file(out, img));
- fclose(out);
- }
- GdipDisposeImage(bitmap);
- GdipFree(scan0);
- GdipDisposeImage(img);
- }
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement