//---------------------------------------------------------- void ofTexture::readToPixels(ofShortPixels & pixels){ #ifndef TARGET_OPENGLES pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glTypeInternal)); bind(); glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_UNSIGNED_SHORT,pixels.getPixels()); unbind(); #endif }
//---------------------------------------------------------- void ofTexture::readToPixels(ofShortPixels & pixels) const { #ifndef TARGET_OPENGLES pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glInternalFormat)); ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT,pixels.getWidth(),pixels.getBytesPerChannel(),pixels.getNumChannels()); glBindTexture(texData.textureTarget,texData.textureID); glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_UNSIGNED_SHORT,pixels.getData()); glBindTexture(texData.textureTarget,0); #endif }
//---------------------------------------------------------- void ofFbo::readToPixels(ofShortPixels & pixels, int attachmentPoint) const{ if(!bIsAllocated) return; #ifndef TARGET_OPENGLES getTexture(attachmentPoint).readToPixels(pixels); #else pixels.allocate(settings.width,settings.height,ofGetImageTypeFromGLType(settings.internalformat)); bind(); int format = ofGetGLFormatFromInternal(settings.internalformat); glReadPixels(0,0,settings.width, settings.height, format, GL_UNSIGNED_SHORT, pixels.getData()); unbind(); #endif }
void ofxDepthImageCompressor::readCompressedPng(string filename, ofShortPixels& pix){ if(!pix.isAllocated()){ pix.allocate(640, 480, 1); } readCompressedPng(filename, pix.getPixels()); }