{"id":4324,"date":"2015-03-04T02:47:15","date_gmt":"2015-03-03T17:47:15","guid":{"rendered":"http:\/\/kako.com\/blog\/?p=4324"},"modified":"2015-03-04T09:33:54","modified_gmt":"2015-03-04T00:33:54","slug":"opencv%e3%81%a7gif%e3%81%ae%e8%aa%ad%e3%81%bf%e6%9b%b8%e3%81%8d%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e3%81%ae%e3%81%a7imgctl-dll%e3%82%92%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"http:\/\/kako.com\/blog\/?p=4324","title":{"rendered":"OpenCV\u3067GIF\u306e\u8aad\u307f\u66f8\u304d\u3067\u304d\u306a\u3044\u306e\u3067imgctl.dll\u3092\u4f7f\u3046"},"content":{"rendered":"<p>OpenCV\u3067GIF\u306e\u8aad\u307f\u66f8\u304d\u3067\u304d\u306a\u3044\u306e\u3067imgctl.dll\u3068\u3044\u3046\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3063\u3066\u307f\u305f\u3002<br \/>\n\u2192 <a href=\"http:\/\/www.vector.co.jp\/soft\/win95\/prog\/se222453.html\">imgctl.dll<\/a><br \/>\nOpenCV\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u3001GIF\u306e\u8aad\u307f\u66f8\u304d\u3060\u3051imgctl.dll\u3092\u4f7f\u3063\u3066\u3001\u3042\u3068\u306e\u753b\u50cf\u51e6\u7406\u306fOpenCV\u3067\u884c\u3046\u3068\u3044\u3046\u4f7f\u3044\u65b9\u3092\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u4ed6\u306b\u3082giflib\u3068\u304blibGD\u3068\u304b\u306e\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u8a66\u3057\u3066\u307f\u305f\u306e\u3060\u3051\u3069\u3001\u81ea\u5206\u306b\u306fimgctl.dll\u304c\u4e00\u756a\u4f7f\u3044\u3084\u3059\u304f\u3066\u7406\u89e3\u3057\u3084\u3059\u304b\u3063\u305f\u3002<br \/>\n<!--more--><\/p>\n<p>\u307e\u305a\u3001GIF\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u306e\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002<br \/>\n\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u3044\u305f\u3002<br \/>\nmain\u95a2\u6570\u3067\u306fload_GIF()\u3092\u547c\u3073\u51fa\u3057\u3066GIF\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001OpenCV\u306ecvSaveImage()\u3067JPEG\u3067\u66f8\u304d\u51fa\u3059\u3068\u3044\u3046\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n#include &lt;windows.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#include &quot;imgctl.h&quot;\r\n#include &quot;opencv2\/opencv.hpp&quot;\r\n\r\nIplImage *load_GIF(char *filename)\r\n{\r\n\tHDIB hDib=NULL;\r\n\tBITMAPINFOHEADER bih;\r\n\tunsigned char *bitmapData;\r\n\tDWORD ret;\r\n\tDWORD dwDataSize = 0;\r\n\tIplImage *image;\r\n\tint wd,ht;\r\n\tint i,j;\r\n\t\r\n\t\/\/ load GIF\r\n\tImgctlErrorClear();\r\n\thDib = GIFtoDIB(filename);\r\n\tret = ImgctlError();\r\n\tif ( ret!=ICERR_NONE )  {\r\n\t\treturn NULL; \/\/ Error: File not found.\r\n\t}\r\n\t\r\n\t\/\/ to 24bit\r\n\tDIBto24Bit(hDib);\r\n\t\r\n\t\/\/ get bitmap data\r\n\tHeadDIB(hDib, &amp;bih);\r\n\tGetDIB(hDib, NULL, NULL, NULL, &amp;dwDataSize);\r\n\tbitmapData = (unsigned char *)malloc(dwDataSize);\r\n\tif (bitmapData==NULL) {\r\n\t\treturn NULL;\r\n\t}\r\n\tGetDIB(hDib, NULL, NULL, bitmapData, &amp;dwDataSize);\r\n\t\r\n\t\/\/ IPL image\r\n\twd=bih.biWidth; ht=bih.biHeight;\r\n\timage = cvCreateImage(cvSize(wd,ht),IPL_DEPTH_8U,3);\r\n\t\r\n\t\/\/ copy bitmap data\r\n\tfor (i=0;i&lt;ht;i++) {\r\n\t\tfor (j=0;j&lt;wd;j++) {\r\n\t\t\timage-&gt;imageData[image-&gt;widthStep*i+j*3  ] = bitmapData[ (j+(ht-i-1)*wd)*3  ];\r\n\t\t\timage-&gt;imageData[image-&gt;widthStep*i+j*3+1] = bitmapData[ (j+(ht-i-1)*wd)*3+1];\r\n\t\t\timage-&gt;imageData[image-&gt;widthStep*i+j*3+2] = bitmapData[ (j+(ht-i-1)*wd)*3+2];\r\n\t\t}\r\n\t}\r\n\tfree(bitmapData);\r\n\tDeleteDIB(hDib);\r\n\treturn image;\r\n}\r\n\r\nint main()\r\n{\r\n\tIplImage *image1;\r\n\t\r\n\t\/\/ load GIF\r\n\timage1 = load_GIF(&quot;test.GIF&quot;);\r\n\tif (image1==NULL) { printf(&quot;Error\\n&quot;); return 1; }\r\n\t\r\n\t\/\/ output to JPEG\r\n\tcvSaveImage(&quot;output.jpg&quot;,image1);\r\n\t\r\n\treturn 0;\r\n}\r\n<\/pre>\n<p>\u6b21\u306b\u3001GIF\u306e\u66f8\u304d\u51fa\u3057\u3082\u4f5c\u3063\u3066\u307f\u305f\u3002<br \/>\n\u4e0a\u8a18\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306e\u9006\u3067\u3001cvLoadImage()\u3067JPEG\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001save_GIF()\u3067GIF\u30d5\u30a1\u30a4\u30eb\u3092\u66f8\u304d\u51fa\u3059\u3068\u3044\u3046\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n#include &lt;windows.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#include &quot;imgctl.h&quot;\r\n#include &quot;opencv2\/opencv.hpp&quot;\r\n\r\nint save_GIF(char *filename,IplImage *image)\r\n{\r\n\tHDIB hDib = NULL;\r\n\tBITMAPINFO bmpInfo;\r\n\tunsigned char *bitmapData;\r\n\tDWORD ret;\r\n\tint wd,ht;\r\n\tint i,j;\r\n\t\r\n\twd = image-&gt;width;\r\n\tht = image-&gt;height;\r\n\tbitmapData = (unsigned char *)malloc(wd*ht*3);\r\n\tif (bitmapData==NULL) {\r\n\t\treturn 1; \/\/ error\r\n\t}\r\n\t\r\n\tZeroMemory(&amp;bmpInfo, sizeof(bmpInfo));\r\n\tbmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);\r\n\tbmpInfo.bmiHeader.biWidth = wd;\r\n\tbmpInfo.bmiHeader.biHeight = ht;\r\n\tbmpInfo.bmiHeader.biPlanes = 1;\r\n\tbmpInfo.bmiHeader.biBitCount = 24;\r\n\tbmpInfo.bmiHeader.biCompression = BI_RGB;\r\n\r\n\tfor (i=0;i&lt;ht;i++) {\r\n\t\tfor (j=0;j&lt;wd;j++) {\r\n\t\t\tbitmapData[ (j+(ht-i-1)*wd)*3  ] = image-&gt;imageData[image-&gt;widthStep*i+j*3];\r\n\t\t\tbitmapData[ (j+(ht-i-1)*wd)*3+1] = image-&gt;imageData[image-&gt;widthStep*i+j*3+1];\r\n\t\t\tbitmapData[ (j+(ht-i-1)*wd)*3+2] = image-&gt;imageData[image-&gt;widthStep*i+j*3+2];\r\n\t\t}\r\n\t}\r\n\t\r\n\t\/\/ create HDIB data\r\n\thDib = CreateDIB(&amp;bmpInfo,bitmapData);\r\n\t\r\n\t\/\/ GIF output\r\n\tret = DIBtoGIF(filename,hDib,FALSE);\r\n\tif (!ret) {\r\n\t\tDeleteDIB(hDib); return 1; \/\/ Error: output failed\r\n\t}\r\n\t\r\n\tfree(bitmapData);\r\n\tDeleteDIB(hDib);\r\n\treturn 0;\r\n}\r\n\r\nint main()\r\n{\r\n\tIplImage *image1;\r\n\tint ret;\r\n\t\r\n\t\/\/ load JPEG\r\n\timage1 = cvLoadImage(&quot;test.jpg&quot;, CV_LOAD_IMAGE_COLOR);\r\n\t\r\n\t\/\/ output to GIF\r\n\tret = save_GIF(&quot;output.gif&quot;,image1);\r\n\tif (ret!=0) { printf(&quot;Error\\n&quot;); return 1; }\r\n\t\r\n\treturn 0;\r\n}\r\n<\/pre>\n<p>\u3068\u308a\u3042\u3048\u305a\u4f5c\u3063\u305f\u3051\u3069\u3001GIF\u5f62\u5f0f\u306f\u3082\u3046\u6642\u4ee3\u9045\u308c\u306a\u306e\u3067\u4f7f\u3046\u30cb\u30fc\u30ba\u306f\u307b\u3068\u3093\u3069\u7121\u3044\u3068\u601d\u3046\u3002<\/p>\n<p>\u3067\u3082\u3053\u308c\u3067\u5927\u4f53\u3001imgctl.dll\u306e\u4f7f\u3044\u65b9\u3092\u30de\u30b9\u30bf\u30fc\u3067\u304d\u305f\u3088\u3046\u3060\u3002<\/p>\n<p>\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3GIF\u306b\u3064\u3044\u3066\u306f\u307e\u3060\u3057\u3070\u3089\u304f\u306f\u4f7f\u308f\u308c\u305d\u3046\u306a\u611f\u3058\u3060\u3057\u3001\u81ea\u5206\u3067\u3082\u3061\u3087\u3063\u3068\u4f5c\u3063\u3066\u307f\u305f\u3044\u30bd\u30d5\u30c8\u304c\u3042\u308b\u306e\u3067\u3001imgctl.dll\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3GIF\u306e\u66f8\u304d\u51fa\u3057\u3068\u304b\u3092\u4f7f\u3063\u3066\u4f55\u304b\u4f5c\u3063\u3066\u307f\u308b\u4e88\u5b9a\u3060\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenCV\u3067GIF\u306e\u8aad\u307f\u66f8\u304d\u3067\u304d\u306a\u3044\u306e\u3067imgctl.dll\u3068\u3044\u3046\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3063\u3066\u307f\u305f\u3002 \u2192 imgctl.dll OpenCV\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u3001GIF\u306e\u8aad\u307f\u66f8\u304d\u3060\u3051imgctl.dll\u3092\u4f7f\u3063\u3066\u3001\u3042\u3068\u306e\u753b\u50cf [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4324"}],"collection":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4324"}],"version-history":[{"count":7,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4324\/revisions"}],"predecessor-version":[{"id":4331,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4324\/revisions\/4331"}],"wp:attachment":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4324"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}