1 //ImageMagick_use_test.cpp : Defines the entry point for the console application.2 //3
4 #include "stdafx.h"
5 #include "wand\MagickWand.h"
6 #include "magick\MagickCore.h"
7 #include "stdio.h"
8 #include "stdlib.h"
9 #include "conio.h"
10 #include "malloc.h"
11
12 #define OUT
13
14 void ThrowWandException(MagickWand*wand)15 {16 char *description;17
18 ExceptionType severity;19 char err_msg[125];20
21 description=MagickGetException(wand,&severity);22 sprintf(err_msg,"%s\nError_Type is %d\n",description,severity);23 //description=(char *) MagickRelinquishMemory(description);
24
25 printf(err_msg);26 }27
28 char* __stdcall GetGrayPixelFormat_16bit( const char* fileName, int width, int height, OUT char*pDestImage );29
30 bool __stdcall GetRGBPixelFormat_16bit( const char* fileName, int width, int height, OUT char* pRed, OUT char* pGreen, OUT char*pBlue);31
32 int _tmain(int argc, _TCHAR*argv[])33 {34
35 char *pDestImage =NULL;36 char *pRed =NULL;37 char *pGreen =NULL;38 char *pBlue =NULL;39 //Allocate 1024*5 Buffer in bytes
40 pDestImage = (char*)malloc(1920*1200*2);41 pRed = (char*)malloc(1920*1200*2);42 pGreen = (char*)malloc(1920*1200*2);43 pBlue = (char*)malloc(1920*1200*2);44
45 memset(pDestImage,0,1920*1200*2);46 memset(pRed, 0, 1920*1200*2);47 memset(pGreen, 0, 1920*1200*2);48 memset(pBlue, 0, 1920*1200*2);49
50 pDestImage = GetGrayPixelFormat_16bit( "C:\\Users\\Yajun Dou\\Desktop\\12.jpg", 1920, 1200, pDestImage);51
52 if(pDestImage ==NULL)53 {54 printf("GetGrayPixelFormat_16bit Failed!\n");55 }56
57 if(GetRGBPixelFormat_16bit("C:\\Users\\Yajun Dou\\Deskto