Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Saved image is empty with data loaded from ofTexture

$
0
0

@yangyangcv wrote:

i'm using ofxMSAOpenCL to do image processing with GPU. just playing with ofxMSAOpenCL's image example. with
clImage[activeImageIndex].getTexture().draw(vidWidth, 200);
the texture could be drawn correctly.
now i want to load the texture data into ofImage and save it to hard disk with the following code:
void ofApp::keyPressed(int key){
if(key == 's'){
ofPixels pixels;
pixels.allocate(vidWidth, vidHeight, OF_PIXELS_RGBA);
clImage_[1].getTexture().readToPixels(pixels);
ofImage img;
string name = ofToString(ofGetFrameNum()) + ".png";
img.setFromPixels(pixels);
img.saveImage(name);
}
}
however, i always got a total blank image. does anybody know the reason?

btw, how could i retrieve the pixel value for each element in ofPixels? e.g. i want to do something like the following:
for(int i=0;i<pixels.size();i++)
std::cout<<pixels[i].getColor()<<std::endl;//compile error for pixels[i].getColor()

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles