SlideShare una empresa de Scribd logo
1 de 64
Descargar para leer sin conexión
‣
‣


‣
‣
‣
‣

‣
‣
‣
‣


‣ 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
‣



‣
//ofImage
ofImage 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();

!   //ofImage
! ofImage myImage;
};
‣
#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);
}
‣
‣
‣



‣

unsigned char * pixels = rioImage.getPixels();



‣
‣


‣
‣
‣
‣
‣
‣
#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();
‣

!   //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);!
!   !    }
!   }
}
‣
‣


‣
‣
‣
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);
!   !      }
!   }
}
‣
‣
‣
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();
!   !    }
!   }
}
‣
‣
‣


‣
‣
‣
‣
#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);
‣
!
!   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);
!   !    }
!   }
}
‣
‣
‣




    R   G   B   R   G   B   R   G   B

‣
‣


‣
‣
‣
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);!
!   !      }
!   }
}
‣
‣



‣
‣
‣
‣
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();
!   !    }
!   }
}
‣
‣
‣
‣


‣
‣


‣
‣
‣
#pragma once

#include "ofMain.h"

class testApp : public ofBaseApp{
public:
    void setup();
    void update();
    void draw();

!    //
     ofVideoGrabber myVideo;
};
‣
#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);
}
‣
‣
‣
#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();
‣

!   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();
!   !    }
!   }
}
‣
‣
‣
‣
#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();
‣
!   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);
!   !    }
!   }
}
‣
‣


‣
‣
‣


‣
‣ http://www.ustream.tv/recorded/16077641
‣
‣
‣
#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;
};
‣
#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();
‣
!   //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());
}
‣
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();
! void keyPressed(int key);
! void mousePressed(int x, int y, int button);
!
! void reset();!
! ofImage img;
! ofImageQualityType quality;
! ofVideoGrabber myVideo;
};
‣
#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());
}
‣
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);
‣
!   //
!   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();
}
‣
‣
‣
‣
‣


‣

Más contenido relacionado

La actualidad más candente

La actualidad más candente (19)

Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)
 
Второй экрана для “Еды". Владимир Павликов. Kelnik. 29.01.2014
Второй экрана для “Еды". Владимир Павликов. Kelnik. 29.01.2014Второй экрана для “Еды". Владимир Павликов. Kelnik. 29.01.2014
Второй экрана для “Еды". Владимир Павликов. Kelnik. 29.01.2014
 
Sbaw090630
Sbaw090630Sbaw090630
Sbaw090630
 
Sbaw091027
Sbaw091027Sbaw091027
Sbaw091027
 
week-24x
week-24xweek-24x
week-24x
 
Dsa 1
Dsa 1Dsa 1
Dsa 1
 
Info clasa
Info clasaInfo clasa
Info clasa
 
Dij
DijDij
Dij
 
python-geohex
python-geohexpython-geohex
python-geohex
 
JavaScript Assíncrono
JavaScript AssíncronoJavaScript Assíncrono
JavaScript Assíncrono
 
Alejandro
AlejandroAlejandro
Alejandro
 
Антон Полухин. C++17
Антон Полухин. C++17Антон Полухин. C++17
Антон Полухин. C++17
 
Daniel snake
Daniel snakeDaniel snake
Daniel snake
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
 
Metodos Numericos
Metodos NumericosMetodos Numericos
Metodos Numericos
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Vatesh
VateshVatesh
Vatesh
 
ບົດລາຍງານ Honda gl09
ບົດລາຍງານ Honda gl09ບົດລາຍງານ Honda gl09
ບົດລາຍງານ Honda gl09
 

Más de Atsushi Tadokoro

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望Atsushi Tadokoro
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようAtsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Atsushi Tadokoro
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2Atsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Atsushi Tadokoro
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションAtsushi Tadokoro
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Atsushi Tadokoro
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Atsushi Tadokoro
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くAtsushi Tadokoro
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリAtsushi Tadokoro
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使うAtsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Atsushi Tadokoro
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得Atsushi Tadokoro
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングAtsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Atsushi Tadokoro
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するAtsushi Tadokoro
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えAtsushi Tadokoro
 

Más de Atsushi Tadokoro (20)

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめよう
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II Processingによるアニメーション
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
 
Tamabi media131118
Tamabi media131118Tamabi media131118
Tamabi media131118
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替え
 

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

  • 1.
  • 5.
  • 6.
  • 9. 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
  • 10. ‣ ‣ //ofImage ofImage myImage; // myImage.loadImage(" "); ! // myImage.draw(float x, float y, float w, float h);
  • 12. ‣ #pragma once #include "ofMain.h" class testApp : public ofBaseApp{ ! public: ! void setup(); ! void update(); ! void draw(); ! //ofImage ! ofImage myImage; };
  • 13. ‣ #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); }
  • 14.
  • 15. ‣ ‣ ‣ unsigned char * pixels = rioImage.getPixels(); ‣
  • 17. ‣ #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();
  • 18. ‣ ! //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);! ! ! } ! } }
  • 19.
  • 21. ‣ 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); ! ! } ! } }
  • 22.
  • 23.
  • 24. ‣ 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(); ! ! } ! } }
  • 25.
  • 26.
  • 28. ‣ #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);
  • 29. ‣ ! ! 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); ! ! } ! } }
  • 30.
  • 31. ‣ ‣ R G B R G B R G B ‣ ‣ ‣ ‣
  • 32. ‣ 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);! ! ! } ! } }
  • 33.
  • 35. ‣ 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(); ! ! } ! } }
  • 36.
  • 39.
  • 40. ‣ #pragma once #include "ofMain.h" class testApp : public ofBaseApp{ public: void setup(); void update(); void draw(); ! // ofVideoGrabber myVideo; };
  • 41. ‣ #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); }
  • 43. ‣ #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();
  • 44. ‣ ! 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(); ! ! } ! } }
  • 45.
  • 47. ‣ #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();
  • 48. ‣ ! 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); ! ! } ! } }
  • 49.
  • 53. ‣ #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; };
  • 54. ‣ #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();
  • 55. ‣ ! //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()); }
  • 56. ‣ void testApp::keyPressed (int key){ ! // ! reset(); } void testApp::mousePressed(int x, int y, int button){ ! // ! reset(); }
  • 57.
  • 58.
  • 59. ‣ #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; };
  • 60. ‣ #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()); }
  • 61. ‣ 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);
  • 62. ‣ ! // ! 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(); }
  • 63.