本文整理汇总了C++中ofPixels::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPixels::resize方法的具体用法?C++ ofPixels::resize怎么用?C++ ofPixels::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPixels
的用法示例。
在下文中一共展示了ofPixels::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setImage
//--------------------------------------------------------------
// set the division rates based on the ALPHA (!) values of the input image
void Rd::setImage(ofPixels input){
input.resize(w, h); // resize input image to simulation dimensions
int numChannels = input.getNumChannels();
for(int i = 0; i < vectorSize; i++){
int a = input[i * numChannels + 3]; // get alpha of pixel
D[i] = a / 255.0;
}
}
示例2: pixSaturation
void ofxImageTS::pixSaturation(ofPixels pixels, int pixelRatio, float saturation) {
if(pixelRatio > 4 || pixelRatio < 0) {
ofLogNotice("Pixel Ratio must be between 0 and 5");
}
else {
ofPixels R,G,B, copy;
if(pixels.getWidth() < pixels.getHeight())
pixels.resize(640,480);
if(pixels.getWidth() > pixels.getHeight())
pixels.resize(480,640);
copy.allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_RGB);
copy = pixels;
R = copy.getChannel(0);
G = copy.getChannel(1);
B = copy.getChannel(2);
int camWidth = pixels.getWidth();
int camHeight = pixels.getHeight();
int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10);
int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10);
float tot = boxWidth*boxHeight;
for (int x = 0; x < camWidth; x += boxWidth) {
for (int y = 0; y < camHeight; y += boxHeight) {
float Red = 0, Green = 0, Blue = 0;
for (int k = 0; k < boxWidth; k++) {
for (int l = 0; l < boxHeight; l++) {
int index = (x + k) + (y + l) * camWidth;
Red += R[index];
Green += G[index];
Blue += B[index];
}
ofColor color;
color.set(Red/tot,Green/tot,Blue/tot);
color.setSaturation(saturation);
ofSetColor(color);
ofFill();
ofDrawRectangle(x, y, boxWidth, boxHeight);
}
}
}
}
}
示例3: pixelateInv
void ofxImageTS::pixelateInv(ofPixels pixels, int pixelRatio, int X, int Y, int W, int H) {
ofPixels R,G,B, Rc, Gc, Bc;
pixels.resize(W,H);
R = pixels.getChannel(0);
G = pixels.getChannel(1);
B = pixels.getChannel(2);
Rc = R;
Gc = G;
Bc = B;
int c = 0;
for(int i = R.size()-1; i > 0; i--){
Rc[c] = R[i];
Gc[c] = G[i];
Bc[c] = B[i];
c++;
}
if(pixelRatio > 4 || pixelRatio < 0) {
ofLogNotice("Pixel Ratio must be between 0 and 5");
}
else {
int camWidth = pixels.getWidth();
int camHeight = pixels.getHeight();
int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10);
int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10);
float tot = boxWidth*boxHeight;
for (int x = 0; x < camWidth; x += boxWidth) {
for (int y = 0; y < camHeight; y += boxHeight) {
float Red = 0, Green = 0, Blue = 0;
for (int k = 0; k < boxWidth; k++) {
for (int l = 0; l < boxHeight; l++) {
int index = (x + k) + (y + l) * camWidth;
Red += Rc[index];
Green += Gc[index];
Blue += Bc[index];
}
ofSetColor(Red/tot,Green/tot,Blue/tot);
ofFill();
ofDrawRectangle(x+X, y+Y, boxWidth, boxHeight);
}
}
}
}
}
示例4: pixelate
void ofxImageTS::pixelate(ofPixels pixels, int pixelRatio, int X, int Y, int W, int H, int form) {
if(pixelRatio > 4 || pixelRatio < 0) {
ofLogNotice("Pixel Ratio must be between 0 and 5");
}
else {
ofPixels R,G,B, copy;
pixels.resize(W,H);
copy.allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_RGBA);
copy = pixels;
R = copy.getChannel(0);
G = copy.getChannel(1);
B = copy.getChannel(2);
int camWidth = pixels.getWidth();
int camHeight = pixels.getHeight();
int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10);
int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10);
float tot = boxWidth*boxHeight;
for (int x = 0; x < camWidth; x += boxWidth) {
for (int y = 0; y < camHeight; y += boxHeight) {
float Red = 0, Green = 0, Blue = 0;
for (int k = 0; k < boxWidth; k++) {
for (int l = 0; l < boxHeight; l++) {
int index = (x + k) + (y + l) * camWidth;
Red += R[index];
Green += G[index];
Blue += B[index];
}
ofSetColor(Red/tot,Green/tot,Blue/tot);
ofFill();
if(form == 1)
ofDrawRectangle(x+X, y+Y, boxWidth, boxHeight);
if(form == 2)
ofDrawBox(x+X, y+Y, boxWidth, boxHeight);
if(form == 3)
ofDrawCircle(x+X, y+Y, boxWidth, boxHeight);
if(form == 4)
ofDrawTriangle(x+X, y+Y, X+x+boxHeight, y+Y, x+X, y+Y+boxWidth);
}
}
}
}
}