Esempio n. 1
0
void Z3DCanvasRenderer::renderInportToImage(const QString &filename, Z3DEye eye)
{
  const Z3DTexture* tex = getImageColorTexture(eye);
  if (!tex) {
    throw Exception("not ready to capture image");
  }
  GLenum dataFormat = GL_BGRA;
  GLenum dataType = GL_UNSIGNED_INT_8_8_8_8_REV;

  if (eye == CenterEye) {
    ZSharedPointer<uint8_t> colorBuffer(new uint8_t[tex->getBypePerPixel(dataFormat, dataType) * tex->getNumPixels()], array_deleter<uint8_t>());
    tex->downloadTextureToBuffer(dataFormat, dataType, colorBuffer.get());
    QImage upsideDownImage(colorBuffer.get(), tex->getWidth(), tex->getHeight(),
                           QImage::Format_ARGB32_Premultiplied);
    QImage image = upsideDownImage.mirrored(false, true);

    if (!ZImage::writeImage(image, filename)) {
      throw Exception("Image writing error");
    }
  } else if (eye == RightEye) {
    const Z3DTexture* leftTex = getImageColorTexture(LeftEye);
    if (!leftTex) {
      throw Exception("not ready to capture image");
    }
    ZSharedPointer<uint8_t> colorBuffer(new uint8_t[leftTex->getBypePerPixel(dataFormat, dataType) * leftTex->getNumPixels()], array_deleter<uint8_t>());
    leftTex->downloadTextureToBuffer(dataFormat, dataType, colorBuffer.get());
    QImage sideBySideImage(tex->getWidth() * 2, tex->getHeight(), QImage::Format_ARGB32_Premultiplied);
    QPainter painter(&sideBySideImage);
    painter.scale(1, -1);
    painter.translate(0, -tex->getHeight());
    QImage upsideDownImageLeft(colorBuffer.get(), tex->getWidth(), tex->getHeight(),
                               QImage::Format_ARGB32_Premultiplied);
    painter.drawImage(0, 0, upsideDownImageLeft);
    tex->downloadTextureToBuffer(dataFormat, dataType, colorBuffer.get());
    QImage upsideDownImageRight(colorBuffer.get(), tex->getWidth(), tex->getHeight(),
                                QImage::Format_ARGB32_Premultiplied);
    painter.drawImage(tex->getWidth(), 0, upsideDownImageRight);

    if (m_renderToImageType == HalfSideBySideStereoView) {
      QImage halfSideBySideImage = sideBySideImage.scaled(
            tex->getWidth(), tex->getHeight(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
      QImageWriter writer(filename);
      writer.setCompression(1);
      if(!writer.write(halfSideBySideImage)) {
        throw Exception(writer.errorString().toStdString());
      }
    } else {
      QImageWriter writer(filename);
      writer.setCompression(1);
      if(!writer.write(sideBySideImage)) {
        throw Exception(writer.errorString().toStdString());
      }
    }
  }
}
Esempio n. 2
0
TextureObjChunk* SimpleFBO::colorTexObj(UInt32 idx) const
{
    TextureBuffer* texBuf = dynamic_cast<TextureBuffer*>(colorBuffer(idx));
    if (texBuf)
        return texBuf->getTexture();

    return nullptr;
}
Esempio n. 3
0
void CubeRender::setBufferSize(const int & w, const int & h)
{
	CudaRender::setBufferSize(w, h);
	imagebase::resetImage((uint *) colorBuffer(),
                (float *) nearDepthBuffer(),
                512,
                w * h );
	CudaBase::CheckCudaError(" reset image");
}
Esempio n. 4
0
void blockEncoder(
		bool init,
		bool color_mode,
		int  sampling,
		unsigned short imagewidth,
		unsigned short imageheight,
		unsigned char Standard_Luminance_Quantization_Table[64] ,
		unsigned char Standard_Chromiance_Quantization_Table0[64] ,
		unsigned char Standard_Chromiance_Quantization_Table1[64] ,
		const unsigned char buffer[MAX_ROWBUF_WIDTH*3*8],

		pixel_queue_t& queue,bool flush

		)
{


	yuv_t yQ[64];
	yuv_t uQ[64];
	yuv_t vQ[64];
	freq_t yfrqQ[64];
	freq_t ufrqQ[64];
	freq_t vfrqQ[64];
	freq_t yquantQ[64];
	freq_t uquantQ[64];
	freq_t vquantQ[64];
	bits_t yBitQ[MAX_HUFF];
	bits_t uBitQ[MAX_HUFF];
	bits_t vBitQ[MAX_HUFF];
	bits_t emptyBitQ[1];

	bitlen_t yBitLenQ[MAX_HUFF];
	bitlen_t uBitLenQ[MAX_HUFF];
	bitlen_t vBitLenQ[MAX_HUFF];
	bitlen_t emptyBitLenQ[1];
	unsigned char yLen, uLen, vLen, emptyLen;
	emptyLen=1;
	bool ydcten, udcten, vdcten, yqen, vqen, uqen, yhen, uhen, vhen;
	colorBuffer( color_mode, sampling, imagewidth, buffer, yQ, uQ, vQ, ydcten, udcten, vdcten);
	dct(ydcten, yQ,yfrqQ, yqen);
	dct(udcten, uQ,ufrqQ, vqen);
	dct(vdcten, vQ,vfrqQ, uqen);
	quant_y(yqen, Standard_Luminance_Quantization_Table, yfrqQ, yquantQ  , yhen);
	quant_u(vqen, Standard_Chromiance_Quantization_Table0, ufrqQ, uquantQ, uhen);
	quant_v(uqen, Standard_Chromiance_Quantization_Table1, vfrqQ, vquantQ, vhen);

	huffman_Y (yhen, yquantQ, yBitQ, yBitLenQ, yLen);
	huffman_UV(uhen, uquantQ, uBitQ, uBitLenQ,U_DATA,uLen);
	huffman_UV(vhen, vquantQ, vBitQ, vBitLenQ,V_DATA,vLen);

	bitWriter(yBitQ, yBitLenQ,yLen,false, queue);
	bitWriter(uBitQ, uBitLenQ,uLen,false, queue);
	bitWriter(vBitQ, vBitLenQ,vLen,false, queue);
	bitWriter(emptyBitQ, emptyBitLenQ,emptyLen,false, queue);
}
Esempio n. 5
0
void CubeRender::render()
{
	cuber::setBoxFaces();
	cuber::setRenderRect((int *)&rect() );
    cuber::setFrustum((float *)rayFrameVec());
#if 0
	cuber::drawPyramid((uint *) colorBuffer(),
                (float *) nearDepthBuffer(),
				tileSize(),
				tileX(), tileY(),
				m_devicePyramidPlanes->bufferOnDevice(),
				m_devicePyramidBox->bufferOnDevice() );
#else 
	cuber::drawVoxel((uint *) colorBuffer(),
                (float *) nearDepthBuffer(),
				tileSize(),
				tileX(), tileY(),
				m_deviceVoxels->bufferOnDevice() );
#endif
	CudaBase::CheckCudaError(" render image");
}
Esempio n. 6
0
unsigned DrawingBuffer::prepareTexture(WebKit::WebTextureUpdater& updater)
{
    if (!m_context || !m_colorBuffer)
        return 0;

    prepareBackBuffer();

    m_context->flush();
    m_context->markLayerComposited();

    unsigned textureId = frontColorBuffer();
    if (requiresCopyFromBackToFrontBuffer())
        updater.appendCopy(colorBuffer(), textureId, size());

    return textureId;
}
Esempio n. 7
0
unsigned DrawingBuffer::frontColorBuffer() const
{
    return colorBuffer();
}
ModelPtr MultiPointCloud::model( )
{

    // Count all points that need to be exported
    pc_attr_it it;
    size_t c = 0;
    for(it = m_clouds.begin(); it != m_clouds.end(); it++)
    {
        PointCloud* pc = it->second->cloud;
        if(pc->isActive())
        {
            vector<uColorVertex>::iterator p_it;
            for(p_it = pc->m_points.begin(); p_it != pc->m_points.end(); p_it++)
            {
                c++;
            }
        }
    }


    // Create a new model and save points
    PointBufferPtr pcBuffer( new PointBuffer);
    floatArr pointBuffer(new float[3 * c]);
    ucharArr colorBuffer(new unsigned char[3 * c]);
    c = 0;

    for(it = m_clouds.begin(); it != m_clouds.end(); it++)
    {
        PointCloud* pc = it->second->cloud;
        if(pc->isActive())
        {
            vector<uColorVertex>::iterator p_it;
            for(p_it = pc->m_points.begin(); p_it != pc->m_points.end(); p_it++)
            {
                size_t bufferPos = 3 * c;

                uColorVertex v = *p_it;
                pointBuffer[bufferPos    ] = v.x;
                pointBuffer[bufferPos + 1] = v.y;
                pointBuffer[bufferPos + 2] = v.z;

                colorBuffer[bufferPos    ] = v.r;
                colorBuffer[bufferPos + 1] = v.g;
                colorBuffer[bufferPos + 2] = v.b;

                c++;
            }
        }

    }

    pcBuffer->setPointArray(pointBuffer, c);
    pcBuffer->setPointColorArray(colorBuffer, c);

    ModelPtr modelPtr(new Model);
    modelPtr->m_pointCloud = pcBuffer;


    return modelPtr;

}