Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
‣‣‣‣‣‣‣‣‣
‣‣ http://goo.gl/T5sov
‣‣‣
‣
‣
‣‣
‣‣
‣    R G     B   A   R   G   B   A   R    R   G   B   R   G   B   R   G   B    K   K   K   K   K   K   K   K   K
‣‣//ofImageofImage myImage;//myImage.loadImage("           ");!//myImage.draw(float x, float y, float w, float h);
‣‣‣
‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!   ...
‣#include "testApp.h"void testApp::setup(){! ofBackground(0, 0, 0);!! //!   myImage.loadImage("t_hero.png");!}void testApp...
‣
‣‣‣unsigned char * pixels = rioImage.getPixels();‣
‣‣‣‣‣‣
‣#include "testApp.h"void testApp::setup(){! ofBackground(0, 0, 0);!! //!   myImage.loadImage("t_hero.png");}void testApp:...
‣!   //20                             Rect!   int skip = 20;!   for (int i = 0; i < myImage.width; i = i + skip){!   !    ...
‣
‣‣‣
‣void testApp::draw(){! //!   int left = (ofGetWidth() - myImage.width) / 2;!   int top = (ofGetHeight() - myImage.height)...
‣
‣
‣void testApp::draw(){! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! o...
‣
‣
‣‣‣‣
‣#include "testApp.h"void testApp::setup(){! ofBackground(255, 255, 255);! //!   myImage.loadImage("t_hero.png");!!   //8!...
‣!!   for (int i = 0; i < myImage.width; i = i + skip){!   !    for (int j = 0; j < myImage.height; j = j + skip){!   !   ...
‣
‣‣    R   G   B   R   G   B   R   G   B‣‣‣‣
‣void testApp::draw(){! //!   int left = (ofGetWidth() - myImage.width) / 2;!   int top = (ofGetHeight() - myImage.height)...
‣
‣‣‣‣
‣void testApp::draw(){! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! o...
‣
‣‣
‣‣‣‣
‣
‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{public:    void setup();    void update();    void draw()...
‣#include "testApp.h"void testApp::setup(){! ofSetFrameRate(60);! ofBackground(0, 0, 0);!   //640x480 pixel    myVideo.ini...
‣‣
‣#include "testApp.h"void testApp::setup(){! ofSetFrameRate(60);! ofBackground(0, 0, 0);! ofSetRectMode(OF_RECTMODE_CENTER...
‣!   int skip = 12;!   for (int i = 0; i < myVideo.width; i = i + skip){!   !    for (int j = 0; j < myVideo.height; j = j...
‣
‣‣
‣#include "testApp.h"void testApp::setup(){! ofSetFrameRate(60);! ofBackground(255, 255, 255);! ofSetRectMode(OF_RECTMODE_...
‣!   int skip = 8;!   ofTranslate(left, top+skip);!   ofSetColor(0, 0, 0);!   for (int i = 0; i < myVideo.width; i = i + s...
‣
‣‣
‣‣‣‣ http://www.ustream.tv/recorded/16077641
‣‣
‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp {!public:! void setup();! void update();! void draw();! v...
‣#include "testApp.h"void testApp::setup() {! ofSetFrameRate(60);! ofSetBackgroundAuto(false);! //Jpeg!   quality = OF_IMA...
‣!   //Jepg!   char * buffer = file.getBinaryBuffer();!   //!   int whichByte = (int) ofRandom(fileSize);!   //ON     bit!...
‣void testApp::keyPressed   (int key){! //!   reset();}void testApp::mousePressed(int x, int y, int button){! //!   reset(...
‣
‣
‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp {!public:! void setup();! void update();! void draw();! v...
‣#include "testApp.h"void testApp::setup() {! ofSetFrameRate(60);! quality = OF_IMAGE_QUALITY_WORST;! //!   myVideo.initGr...
‣void testApp::update() {! //Jpeg!   string compressedFilename = "compressed.jpg";!   //Jpeg!   img.saveImage(compressedFi...
‣!   //!   float coin = ofRandom(100);!   if (coin > 95) {!   !    reset();!   }}void testApp::draw() {! //glitch!   ofSet...
‣
‣‣‣‣‣
openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII
Upcoming SlideShare
Loading in …5
×
Upcoming SlideShare
openFrameworks基礎 たくさんの図形を動かす 静的配列と動的配列 - 芸大グラフィックスプログラミング演習B
Next
Download to read offline and view in fullscreen.

Share

openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII

Download to read offline

Related Audiobooks

Free with a 30 day trial from Scribd

See all

openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII

  1. 1. ‣‣‣‣‣‣‣‣‣
  2. 2. ‣‣ http://goo.gl/T5sov
  3. 3. ‣‣‣
  4. 4.
  5. 5.
  6. 6. ‣‣
  7. 7. ‣‣
  8. 8. ‣ R G B A R G B A R R G B R G B R G B K K K K K K K K K
  9. 9. ‣‣//ofImageofImage myImage;//myImage.loadImage(" ");!//myImage.draw(float x, float y, float w, float h);
  10. 10. ‣‣‣
  11. 11. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();! //ofImage! ofImage myImage;};
  12. 12. ‣#include "testApp.h"void testApp::setup(){! ofBackground(0, 0, 0);!! //! myImage.loadImage("t_hero.png");!}void testApp::update(){}void testApp::draw(){! //! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;!! //! myImage.draw(left, top);}
  13. 13.
  14. 14. ‣‣‣unsigned char * pixels = rioImage.getPixels();‣
  15. 15. ‣‣‣‣‣‣
  16. 16. ‣#include "testApp.h"void testApp::setup(){! ofBackground(0, 0, 0);!! //! myImage.loadImage("t_hero.png");}void testApp::update(){}void testApp::draw(){! //! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! ofTranslate(left, top);!! //! unsigned char * pixels = myImage.getPixels();
  17. 17. ‣! //20 Rect! int skip = 20;! for (int i = 0; i < myImage.width; i = i + skip){! ! for (int j = 0; j < myImage.height; j = j + skip){! ! ! int brightness = pixels[j*myImage.width + i];! ! ! ofSetColor(brightness, brightness, brightness);! ! ! ofRect(i, j, skip, skip);!! ! }! }}
  18. 18.
  19. 19. ‣‣‣
  20. 20. ‣void testApp::draw(){! //! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! ofTranslate(left, top);!! //! unsigned char * pixels = myImage.getPixels();! //10 Rect! int skip = 12;! ofSetColor(0, 0, 0);! for (int i = 0; i < myImage.width; i = i + skip){! ! for (int j = 0; j < myImage.height; j = j + skip){! ! ! int brightness = pixels[j*myImage.width + i];! ! ! // (%)! ! ! float pct = 1.0 - brightness / 255.0f;! ! ! //! ! ! ofCircle(i, j, pct * skip * 0.5);! ! }! }}
  21. 21.
  22. 22.
  23. 23. ‣void testApp::draw(){! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! ofTranslate(left, top);! unsigned char * pixels = myImage.getPixels();! int skip = 8;! ofSetColor(255, 255, 255);! ofSetLineWidth(3);! for (int i = 0; i < myImage.width; i = i + skip){! ! for (int j = 0; j < myImage.height; j = j + skip){! ! ! int brightness = pixels[j*myImage.width + i];! ! ! float pct = 1.0 - brightness / 255.0f;! ! ! //! ! ! ofPushMatrix();! ! ! ofTranslate(i, j);! ! ! ofRotateZ(pct * 90);! ! ! ofLine(-skip, 0, skip, 0);! ! ! ofPopMatrix();! ! }! }}
  24. 24.
  25. 25.
  26. 26. ‣‣‣‣
  27. 27. ‣#include "testApp.h"void testApp::setup(){! ofBackground(255, 255, 255);! //! myImage.loadImage("t_hero.png");!! //8! pixelString = " .-+*a&@";!}void testApp::update(){!}void testApp::draw(){! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! ofTranslate(left, top);! unsigned char * pixels = myImage.getPixels();! int skip = 6;! ofSetColor(0, 0, 0);
  28. 28. ‣!! for (int i = 0; i < myImage.width; i = i + skip){! ! for (int j = 0; j < myImage.height; j = j + skip){! ! ! int brightness = pixels[j*myImage.width + i];! ! ! float pct = 1.0 - brightness / 255.0f;! ! ! //! ! ! string str = pixelString.substr(int(pct * 8),1);! ! ! //! ! ! ofDrawBitmapString(str, i, j);! ! }! }}
  29. 29.
  30. 30. ‣‣ R G B R G B R G B‣‣‣‣
  31. 31. ‣void testApp::draw(){! //! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! ofTranslate(left, top);!! //! unsigned char * pixels = myImage.getPixels();! //10 Rect! int skip = 10;! for (int i = 0; i < myImage.width; i = i + skip){! ! for (int j = 0; j < myImage.height; j = j + skip){! ! ! //RGB! ! ! int r = pixels[j * myImage.width * 3 + i * 3];! ! ! int g = pixels[j * myImage.width * 3 + i * 3 + 1];! ! ! int b = pixels[j * myImage.width * 3 + i * 3 + 2];! ! ! //! ! ! ofSetColor(r, g, b);! ! ! ofRect(i, j, skip, skip);!! ! }! }}
  32. 32.
  33. 33. ‣‣‣‣
  34. 34. ‣void testApp::draw(){! int left = (ofGetWidth() - myImage.width) / 2;! int top = (ofGetHeight() - myImage.height) / 2;! ofTranslate(left, top);! unsigned char * pixels = myImage.getPixels();! int skip = 8;! for (int i = 0; i < myImage.width; i = i + skip){! ! for (int j = 0; j < myImage.height; j = j + skip){! ! ! int r = pixels[j * myImage.width * 3 + i * 3];! ! ! int g = pixels[j * myImage.width * 3 + i * 3 + 1];! ! ! int b = pixels[j * myImage.width * 3 + i * 3 + 2];! ! ! int brightness = (r + g + b) / 3.0f * 255.0f;! ! ! float pct = 1.0 - (r + g + b) / 3.0f / 255.0f;! ! ! //! ! ! ofSetColor(r, g, b);! ! ! ofPushMatrix();! ! ! ofTranslate(i, j);! ! ! ofRotateZ(pct * 360);! ! ! ofLine(-pct*skip*4, 0, pct*skip*4, 0);! ! ! ofPopMatrix();! ! }! }}
  35. 35.
  36. 36. ‣‣
  37. 37. ‣‣‣‣
  38. 38.
  39. 39. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{public: void setup(); void update(); void draw();! // ofVideoGrabber myVideo;};
  40. 40. ‣#include "testApp.h"void testApp::setup(){! ofSetFrameRate(60);! ofBackground(0, 0, 0);! //640x480 pixel myVideo.initGrabber(640, 480, true);}void testApp::update(){! // myVideo.update();}void testApp::draw(){! //! int left = (ofGetWidth() - myVideo.width) / 2;! int top = (ofGetHeight() - myVideo.height) / 2;! ofTranslate(left, top);!! //! myVideo.draw(0, 0);}
  41. 41. ‣‣
  42. 42. ‣#include "testApp.h"void testApp::setup(){! ofSetFrameRate(60);! ofBackground(0, 0, 0);! ofSetRectMode(OF_RECTMODE_CENTER);!! //640x480 pixel myVideo.initGrabber(800, 600, true);}void testApp::update(){! // myVideo.update();}void testApp::draw(){! //! int left = (ofGetWidth() - myVideo.width) / 2;! int top = (ofGetHeight() - myVideo.height) / 2;! ofTranslate(left, top);!! //! unsigned char * pixels = myVideo.getPixels();
  43. 43. ‣! int skip = 12;! for (int i = 0; i < myVideo.width; i = i + skip){! ! for (int j = 0; j < myVideo.height; j = j + skip){ //RGB int r = pixels[j * myVideo.width * 3 + i * 3];! ! ! int g = pixels[j * myVideo.width * 3 + i * 3 + 1];! ! ! int b = pixels[j * myVideo.width * 3 + i * 3 + 2];! ! ! //! ! ! int brightness = (r + g + b) / 3.0f * 255.0f;! ! ! float pct = (r + g + b) / 3.0f / 255.0f;! ! ! //! ! ! ofSetColor(255,255,255);! ! ! ofPushMatrix();! ! ! ofTranslate(i, j);! ! ! ofRotateZ(pct * 180);! ! ! ofRect(0, 0, skip * pct, skip * pct);! ! ! ofPopMatrix();! ! }! }}
  44. 44.
  45. 45. ‣‣
  46. 46. ‣#include "testApp.h"void testApp::setup(){! ofSetFrameRate(60);! ofBackground(255, 255, 255);! ofSetRectMode(OF_RECTMODE_CENTER);! //8! pixelString = " .-+*a&@";! //640x480 pixel myVideo.initGrabber(800, 600, true);}void testApp::update(){! // myVideo.update();}void testApp::draw(){! //! int left = (ofGetWidth() - myVideo.width) / 2;! int top = (ofGetHeight() - myVideo.height) / 2;! //! unsigned char * pixels = myVideo.getPixels();
  47. 47. ‣! int skip = 8;! ofTranslate(left, top+skip);! ofSetColor(0, 0, 0);! for (int i = 0; i < myVideo.width; i = i + skip){! ! for (int j = 0; j < myVideo.height; j = j + skip){! ! ! //RGB! ! ! int r = pixels[j * myVideo.width * 3 + i * 3];! ! ! int g = pixels[j * myVideo.width * 3 + i * 3 + 1];! ! ! int b = pixels[j * myVideo.width * 3 + i * 3 + 2];! ! ! //! ! ! float pct = 1.0 - (r + g + b) / 3.0f / 255.0f;! ! ! //! ! ! string str = pixelString.substr(int(pct * 8),1);! ! ! //! ! ! ofDrawBitmapString(str, i, j);! ! }! }}
  48. 48.
  49. 49. ‣‣
  50. 50. ‣‣‣‣ http://www.ustream.tv/recorded/16077641
  51. 51. ‣‣
  52. 52. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp {!public:! void setup();! void update();! void draw();! void keyPressed(int key);! void mousePressed(int x, int y, int button);!! void reset();! ofImage img;! ofImageQualityType quality;};
  53. 53. ‣#include "testApp.h"void testApp::setup() {! ofSetFrameRate(60);! ofSetBackgroundAuto(false);! //Jpeg! quality = OF_IMAGE_QUALITY_WORST;! //! reset();}void testApp::reset() {! //! img.loadImage("input.jpg");}void testApp::update() {! //Jpeg! string compressedFilename = "compressed.jpg";! //Jpeg! img.saveImage(compressedFilename, quality);! ofBuffer file = ofBufferFromFile(compressedFilename);! int fileSize = file.size();
  54. 54. ‣! //Jepg! char * buffer = file.getBinaryBuffer();! //! int whichByte = (int) ofRandom(fileSize);! //ON bit! int whichBit = ofRandom(8);! // ( ?)! char bitMask = 1 << whichBit;! buffer[whichByte] |= bitMask;! //glitch! ofBufferToFile(compressedFilename, file);! //! img.loadImage(compressedFilename);}void testApp::draw() {! //glitch! ofSetColor(255,255,255);! img.draw(0, 0, ofGetWidth(), ofGetHeight());}
  55. 55. ‣void testApp::keyPressed (int key){! //! reset();}void testApp::mousePressed(int x, int y, int button){! //! reset();}
  56. 56.
  57. 57.
  58. 58. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp {!public:! void setup();! void update();! void draw();! void keyPressed(int key);! void mousePressed(int x, int y, int button);!! void reset();!! ofImage img;! ofImageQualityType quality;! ofVideoGrabber myVideo;};
  59. 59. ‣#include "testApp.h"void testApp::setup() {! ofSetFrameRate(60);! quality = OF_IMAGE_QUALITY_WORST;! //! myVideo.initGrabber(320, 240, true);! // ofImage! img.grabScreen(0, 0, ofGetWidth(), ofGetHeight());}void testApp::reset() {! //! myVideo.update();! // 1! myVideo.draw(0, 0, ofGetWidth(), ofGetHeight());! // ofImage! img.grabScreen(0, 0, ofGetWidth(), ofGetHeight());}
  60. 60. ‣void testApp::update() {! //Jpeg! string compressedFilename = "compressed.jpg";! //Jpeg! img.saveImage(compressedFilename, quality);! ofBuffer file = ofBufferFromFile(compressedFilename);! int fileSize = file.size();! //Jepg! char * buffer = file.getBinaryBuffer();! //! int whichByte = (int) ofRandom(fileSize);! //ON bit! int whichBit = ofRandom(8);! // ( ?)! char bitMask = 1 << whichBit;! buffer[whichByte] |= bitMask;! //glitch! ofBufferToFile(compressedFilename, file);! //! img.loadImage(compressedFilename);
  61. 61. ‣! //! float coin = ofRandom(100);! if (coin > 95) {! ! reset();! }}void testApp::draw() {! //glitch! ofSetColor(255);! img.draw(0, 0, ofGetWidth(), ofGetHeight());}void testApp::keyPressed (int key){! reset();}void testApp::mousePressed(int x, int y, int button){! reset();}
  62. 62.
  63. 63. ‣‣‣‣‣
  • SenaKoga

    Aug. 1, 2016
  • AtsushiOgawa1

    Jan. 15, 2016
  • sasakiP

    Jan. 7, 2015
  • shinsukeltajima

    Nov. 8, 2014
  • shinnxsuke

    Aug. 3, 2013
  • nekouo

    Dec. 17, 2011

Views

Total views

17,677

On Slideshare

0

From embeds

0

Number of embeds

8,416

Actions

Downloads

165

Shares

0

Comments

0

Likes

6

×