{"id":26,"date":"2015-08-13T18:16:34","date_gmt":"2015-08-13T09:16:34","guid":{"rendered":"http:\/\/tamatoyaku.com\/blog\/?p=79"},"modified":"2015-08-13T18:16:34","modified_gmt":"2015-08-13T09:16:34","slug":"26","status":"publish","type":"post","link":"https:\/\/p-0.me\/b\/p\/26\/","title":{"rendered":"openFrameworks\u306e\u4f5c\u54c1\u3092gif\u306b\u3059\u308b"},"content":{"rendered":"<p>\u6628\u65e5\u304b\u3089oF\u3092\u3055\u308f\u308a\u59cb\u3081\u3066,Web\u306b\u4f5c\u54c1\u3092\u4e0a\u3052\u305f\u3044\u3068\u601d\u3063\u305f.<br \/>\njs\u306b\u5909\u63db\u3059\u308b\u3088\u308a\u3082gif\u306b\u5909\u63db\u3059\u308b\u307b\u3046\u304c\u3089\u304f\u3060\u3068\u601d\u3063\u305f.<br \/>\n\u5909\u63db\u3059\u308b\u305f\u3081\u306b\u3069\u3046\u3059\u308b\u3079\u304d\u304b\u8abf\u3079\u305f\u3068\u3053\u308d,ofxGifEncoder\u306a\u308b\u3082\u306e\u3042\u308b\u3068\u308f\u304b\u3063\u305f.<br \/>\n<!--more--><br \/>\n\u524d\u306b\u3082\u66f8\u3044\u305f\u3093\u3060\u3051\u3069,\u30d1\u30b9\u3092\u901a\u3057\u3066\u4f7f\u3063\u3066\u307f\u308b\u3068ofxGifEncoder.cpp\u306eLine51\u3068Line56\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3044\u308b.<br \/>\nimg.w\u3068img.h\u3068img.bpp\u306fprotected\u3060\u304b\u3089\u30c0\u30e1,\u3068\u3044\u3046\u5185\u5bb9\u3060\u3063\u305f.\u305d\u308c\u305e\u308cgetWidth()\u3068getHeight()\u3068img.getPixelsRef().getBitsPerPixel()\u3067\u66f8\u304d\u306a\u304a\u3057\u305f.<br \/>\n\u305d\u306e\u4ed6\u306f\u7279\u306b\u306a\u306b\u3082\u306a\u304f,\u666e\u901a\u306b\u4f7f\u3048\u305f.<br \/>\n&nbsp;<br \/>\n\u81ea\u5206\u3067\u4f7f\u3063\u3066\u307f\u305f\u3068\u304d\u306e\u30b3\u30fc\u30c9\u306f<a href=\"https:\/\/github.com\/pome1618\/ofHeart_gif\/\">\u3053\u308c<\/a><br \/>\n\u203b\u30d1\u30b9\u3068\u304b.vcxproj\u306e\u30d1\u30b9\u90e8\u5206\u3068\u304b\u66f8\u304d\u63db\u3048\u306a\u3044\u3068\u52d5\u304b\u306a\u3044\u3068\u601d\u3046.\u3042\u3068VS2015\u3067.<br \/>\n&nbsp;<br \/>\n\u4f7f\u3044\u65b9\u306f,\u307e\u305a\u30d1\u30b9\u3092\u901a\u3059.<br \/>\n\u3046\u307e\u304f\u3067\u304d\u306a\u304b\u3063\u305f\u3089.vcxproj\u3092\u3044\u3058\u3063\u3066\u8ffd\u52a0\u3059\u308b.<br \/>\n&nbsp;<br \/>\n\u4f7f\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30d8\u30c3\u30c0\u3067,ofxGifEncoder\u578b\u306e\u5909\u6570\u3092\u5ba3\u8a00\u3059\u308b(\u3053\u3053\u3067\u306fgifEncoder\u3068\u3059\u308b).<br \/>\nsetup\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b.<\/p>\n<pre class=\"lang:c++ decode:true \" title=\"setup\">void ofApp::setup() {\n\t\/*---\u3044\u308d\u3044\u308d\u306a\u51e6\u7406---*\/\n\tgifEncoder.setup(ofGetWidth(), ofGetHeight());\n\tgifEncoder.setDitherMode(OFX_GIF_DITHER_NONE);\n\tofAddListener(ofxGifEncoder::OFX_GIF_SAVE_FINISHED, this, &amp;ofApp::onGifSaved);\n}<\/pre>\n<p>\u6b21\u306b,draw\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b.\u3053\u3053\u3067\u306f,\u30d5\u30ec\u30fc\u30e0\u30ec\u30fc\u30c8\u309260\u3068\u3057,3\u79d2\u3054\u304b\u30896\u79d2\u5f8c\u307e\u30670.1\u79d2\u523b\u307f\u3067\u30d5\u30ec\u30fc\u30e0\u3092\u64ae\u3063\u3066\u3044\u308b.<br \/>\nif()\u306e\u4e2d\u306e\u6570\u5b57\u3092\u8272\u3005\u3044\u3058\u308c\u3070\u597d\u304d\u306b\u64ae\u308b\u3053\u3068\u304c\u3067\u304d\u308b.<\/p>\n<pre class=\"lang:c++ decode:true\" title=\"draw\">void ofApp::draw() {\n\t\/*---\u63cf\u753b\u51e6\u7406---*\/\n\tif (ofGetFrameNum()&gt;=180&amp;&amp;ofGetFrameNum() % 6 == 0) {\n\t\tcaptureFrame();\n\t}\n\tif (ofGetFrameNum() == 360) {\n\t\tgifEncoder.save(\"result.gif\");\n\t}\n}<\/pre>\n<p>captureFrame()\u3092\u8ffd\u52a0\u3059\u308b.\u3053\u3053\u3067\u4fdd\u5b58\u3059\u308b\u7bc4\u56f2\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b.<\/p>\n<pre class=\"lang:c++ decode:true \" title=\"captureFrame\">void ofApp::captureFrame() {\n\tofImage img;\n\timg.grabScreen(0, 0, ofGetWidth(), ofGetHeight());\n\tgifEncoder.addFrame(img);\n}<\/pre>\n<p>&nbsp;<br \/>\n\u6700\u5f8c\u306b,onGifSaved\u3092\u8ffd\u52a0\u3059\u308b.\u4fdd\u5b58\u3059\u308b\u3068\u304d\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u4e0d\u8981\u3067\u3042\u308c\u3070,onGisSaved\u3068setup\u306e\u4e2d\u306e5\u884c\u76ee(ofAddEventListenner)\u306f\u3044\u3089\u306a\u3044.<\/p>\n<pre class=\"lang:c++ decode:true \" title=\"onGifSaved\">void ofApp::onGifSaved(string &amp;fileName) {\n\tcout &lt;&lt; \"gif saved as \" &lt;&lt; fileName &lt;&lt; endl;\n}<\/pre>\n<p>&nbsp;<br \/>\n\u81ea\u5206\u306f\u9069\u5f53\u306agif\u304c\u64ae\u308c\u308c\u3070\u3088\u304b\u3063\u305f\u306e\u3067,ofxGifEncoder\u3092\u4f7f\u3063\u305f\u304c,\u666e\u901a\u306b\u30a6\u30a3\u30f3\u30c9\u30a6\u3092gif\u3067\u30ad\u30e3\u30d7\u30c1\u30e3\u3057\u305f\u65b9\u304c\u65e9\u304b\u3063\u305f\u304b\u3082\u3057\u308c\u306a\u3044.<br \/>\n\u307e\u3042,\u3053\u3063\u3061\u306e\u307b\u3046\u304c\u5fdc\u7528\u3082\u52b9\u304f\u3057,\u826f\u3057\u3068\u3057\u3088\u3046.<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u65e5\u304b\u3089oF\u3092\u3055\u308f\u308a\u59cb\u3081\u3066,Web\u306b\u4f5c\u54c1\u3092\u4e0a\u3052\u305f\u3044\u3068\u601d\u3063\u305f. js\u306b\u5909\u63db\u3059\u308b\u3088\u308a\u3082gif\u306b\u5909\u63db\u3059\u308b\u307b\u3046\u304c\u3089\u304f\u3060\u3068\u601d\u3063\u305f. \u5909\u63db\u3059\u308b\u305f\u3081\u306b\u3069\u3046\u3059\u308b\u3079\u304d\u304b\u8abf\u3079\u305f\u3068\u3053\u308d,ofxGifEncoder\u306a\u308b\u3082\u306e\u3042\u308b\u3068\u308f\u304b\u3063\u305f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":0,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}