本文整理汇总了C++中ofImage::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ ofImage::getWidth方法的具体用法?C++ ofImage::getWidth怎么用?C++ ofImage::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofImage
的用法示例。
在下文中一共展示了ofImage::getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(){
wc.begin();
if(!switchVideo){
wc.setUniformTexture("colorMap", img.getTexture(), 1);
wc.setUniformTexture("heightMap",gray.getTexture(), 2);
}
else{
wc.setUniformTexture("colorMap", player.getTexture(), 1);
fboDepth.begin();
player.draw(0,0);
fboDepth.end();
wc.setUniformTexture("heightMap",fboDepth.getDepthTexture(),2);
}
wc.setUniform1f("time", ofGetElapsedTimef()*time);
wc.setUniform1f("gradientStep", stepGradient);
wc.setUniform1f("advectStep", advectStep);
wc.setUniform1f("flipHeightMap",flipHeightMap);
wc.setUniform4f("advectMatrix",advectMatrix->w,advectMatrix->x,advectMatrix->y,advectMatrix->z);
fbo.draw(0,0);
wc.end();
img.draw(0,0,img.getWidth()/4,img.getHeight()/4);
player.draw(img.getWidth()/4,0,img.getWidth()/4,img.getHeight()/4);
gui.draw();
}
示例2: colorWiring
// image2data converts an image to OctoWS2811's raw data format.
// The number of vertical pixels in the image must be a multiple
// of 8. The data array must be the proper size for the image.
//--------------------------------------------------------------
void ofxTeensyOcto::image2data(ofImage image, unsigned char* data, bool layout)
{
int offset = 3;
int x, y, xbegin, xend, xinc, mask;
int linesPerPin = image.getHeight() / 8;
int* pixel = new int[8];
// get the copied image pixels
pixels2 = image.getPixels();
// 2d array of our pixel colors
for (int x = 0; x < ledWidth; x++)
{
for (int y = 0; y < (ledHeight * stripsPerPort * numPortsMain); y++)
{
int loc = x + y * ledWidth;
colors[loc] = pixels2.getColor(x, y);
}
}
for (y = 0; y < linesPerPin; y++)
{
if ((y & 1) == (layout ? 0 : 1))
{
// even numbered rows are left to right
xbegin = 0;
xend = image.getWidth();
xinc = 1;
}
else
{
// odd numbered rows are right to left
xbegin = image.getWidth() - 1;
xend = -1;
xinc = -1;
}
for (x = xbegin; x != xend; x += xinc)
{
for (int i=0; i < 8; i++)
{
int temploc = x + (y + linesPerPin * i) * image.getWidth();
pixel[i] = colors[temploc].getHex();
pixel[i] = colorWiring(pixel[i]);
}
// convert 8 pixels to 24 bytes
for (mask = 0x800000; mask != 0; mask >>= 1)
{
unsigned char b = 0;
for (int i=0; i < 8; i++)
{
if ((pixel[i] & mask) != 0) b |= (1 << i);
}
data[offset++] = b;
}
}
}
}
示例3: DNA
genImg::genImg(ofImage &src, int scale, int nColors) {
dna = DNA(src.getWidth()*scale * src.getHeight()*scale, nColors);
img.allocate(src.getWidth()*scale, src.getHeight()*scale, OF_IMAGE_COLOR);
heatmap.allocate(src.getWidth()*scale, src.getHeight()*scale, OF_IMAGE_COLOR);
fitness = 1;
}
示例4: drawTitle
void RunningDraw::drawTitle(ofImage title){
Settings* settings = Settings::getInstance();
float title_x= settings->getWidth() / 2 - title.getWidth() * SCALE/2;
float title_y = settings->getTitleY();
title.draw(title_x, title_y, title.getWidth() * SCALE, title.getHeight() * SCALE);
}
示例5: setup
//-------------------------------------------------------------------------
void ofxRfeUIImageButton::setup(ofImage _button_image, float _x, float _y){
x = _x;
y = _y;
w = _button_image.getWidth();
h = _button_image.getHeight();
buttonImage = _button_image;
buttonImageHighlight = _button_image;
ofPixels pixels = buttonImageHighlight.getPixelsRef();
for (int x = 0; x < buttonImageHighlight.getWidth(); x++) {
for (int y = 0; y < buttonImageHighlight.getHeight(); y++) {
ofColor cur = pixels.getColor(x, y);
cur.r = 255 - cur.r;
cur.g = 255 - cur.g;
cur.b = 255 - cur.b;
pixels.setColor(x, y, cur);
}
}
buttonImageHighlight.setFromPixels(pixels);
}
示例6: saveStencilToHex
string ofxBaseGui::saveStencilToHex(ofImage& img) {
stringstream strm;
int width = img.getWidth();
int height = img.getHeight();
int n = width * height;
unsigned char cur = 0;
int shift = 0;
strm << "{";
for(int i = 0; i < n;) {
if(img.getPixels()[i * 4 + 3] > 0) {
cur |= 1 << shift;
}
i++;
if(i % 8 == 0) {
strm << "0x" << hex << (unsigned int) cur;
cur = 0;
shift = 0;
if(i < n) {
strm << ",";
}
} else {
shift++;
}
}
strm << "}";
return strm.str();
}
示例7: setup
void setup(float x, float y, string path, string videoPath){
img.loadImage(path);
r.set(x,y,img.getWidth(),img.getHeight());
video = videoPath;
thumbPath = path;
loadPos();
}
示例8: inBound
bool StateCreateOrigami::inBound(ofTouchEventArgs & touch, ofImage mImage, ofPoint pos, float scale){
if (touch.x < pos.x + mImage.getWidth()*scale + offset && touch.x > pos.x - offset && touch.y < pos.y + mImage.getHeight()*scale + offset && touch.y > pos.y - offset) {
return true;
}
return false;
}
示例9: draw
void draw() {
ofBackgroundGradient(64, 0);
if(reflect || sreflect)
env.draw(0,0,env.getWidth()/8,env.getHeight()/8);
if(sreflect)
env1.draw(env.getWidth()/8,0,env1.getWidth()/8,env1.getHeight()/8);
ofEnableDepthTest();
cam.begin();
shader.begin();
if(sreflect){
// shader.setUniform3f("CameraPos",cam.getGlobalPosition().x, cam.getGlobalPosition().y, cam.getGlobalPosition().z);
// shader.setUniformMatrix4f("ModelWorld4x4",cam.getGlobalTransformMatrix());
shader.setUniform3f("CameraPos",cam.getPosition().x, cam.getPosition().y, cam.getPosition().z);
shader.setUniformMatrix4f("ModelWorld4x4",cam.getModelViewMatrix());//getLocalTransformMatrix());
shader.setUniformTexture("frontMap", env,1);
shader.setUniformTexture("backMap", env1,2);
}
if(reflect){
shader.setUniformTexture("colorMap",env1,1);
shader.setUniformTexture("envMap", env,2);
}else if(sreflect==false){
shader.setUniformTexture("texture", img, 1);
shader.setUniform1f("time", ofGetElapsedTimef());
}
if(cube)
ofDrawBox(200);
else {
ofTranslate(0,-150,0);
ofRotateX(-90);
ofRotateY(-90);
ofRotateZ(45);
model.drawFaces();
}
shader.end();
cam.end();
ofDisableDepthTest();
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}
示例10: getVertexFromImg
ofVec3f getVertexFromImg(ofImage& img, int x, int y) {
ofColor color = img.getColor(x, y);
if(color.a > 200) { //adjust to get a good image
float z = ofMap(color.a, 200, 255, -480, 480); //mapping alpha to a good range
return ofVec3f(x - img.getWidth() /2, y - img.getHeight() / 2, z);
} else {
return ofVec3f(0, 0, 0);
}
}
示例11: getVertexFromImg
ofVec3f getVertexFromImg(ofImage& img, int x, int y) {
ofColor color = img.getColor(x, y);
if(color.a > 0) {
float z = ofMap(color.a, 0, 255, -480, 480);
return ofVec3f(x - img.getWidth() / 2, y - img.getHeight() / 2, z);
} else {
return ofVec3f(0, 0, 0);
}
}
示例12: makeThumb
void makeThumb(string vidPath, string thumb){
ofVideoPlayer tmp;
tmp.loadMovie(vidPath);
tmp.play();
tmp.setPosition(0.3);
ofImage img;
img.setFromPixels( tmp.getPixelsRef() );
img.resize(120, 120.0f * (img.getHeight() / img.getWidth()) );
img.saveImage(thumb);
}
示例13: detect
//-----------------------------------------------------
void ofxSURFTracker::detect(ofImage &img) {
int inputWidth = img.getWidth();
int inputHeight = img.getHeight();
if(inputWidth < width || inputHeight < height) {
return; // detection impossible, because I can't crop out of this image
}
detect(img.getPixels(), inputWidth, inputHeight);
}
示例14: getVertexFromImg
ofVec3f getVertexFromImg(ofImage& pastImg, int x, int y) {
ofColor color = pastImg.getColor(x, y);
if(color.a > 0) {
float z = ofMap(color.a, 0, 255, -480, 480);
// this maps this to -480, 480
return ofVec3f(x - pastImg.getWidth() / 2, y - pastImg.getHeight() / 2, z);
} else {
return ofVec3f(0, 0, 0);
}
}
示例15: setup
//--------------------------------------------------------------
void testApp::setup(){
quadmesh.create(150, 50, 400, 300, 8);
quadimage.loadImage("1.jpg");
quadtexture = genTex(quadimage.getWidth(), quadimage.getHeight(), quadimage.getPixels());
// if use GL_TEXTURE_RECTANGLE, change texture coord from [1,1] to [width, height]
//quadmesh.ResetTextureCoords(quadimage.getWidth(), quadimage.getHeight());
}