예제 #1
0
      void
      MinimalTIFFWriter::setupIFD() const
      {
        // Default to single strips for now.
        ifd->setImageWidth(getSizeX());
        ifd->setImageHeight(getSizeY());

        ifd->setTileType(tiff::STRIP);
        ifd->setTileWidth(getSizeX());
        ifd->setTileHeight(1U);

        ome::compat::array<dimension_size_type, 3> coords = getZCTCoords(getPlane());

        dimension_size_type channel = coords[1];

        ifd->setPixelType(getPixelType());
        ifd->setBitsPerSample(bitsPerPixel(getPixelType()));
        ifd->setSamplesPerPixel(getRGBChannelCount(channel));

        const boost::optional<bool> interleaved(getInterleaved());
        if (isRGB(channel) && interleaved && *interleaved)
          ifd->setPlanarConfiguration(tiff::CONTIG);
        else
          ifd->setPlanarConfiguration(tiff::SEPARATE);

        // This isn't necessarily always true; we might want to use a
        // photometric interpretation other than RGB with three
        // subchannels.
        if (isRGB(channel) && getRGBChannelCount(channel) == 3)
          ifd->setPhotometricInterpretation(tiff::RGB);
        else
          ifd->setPhotometricInterpretation(tiff::MIN_IS_BLACK);
      }
예제 #2
0
bool ossimOpjJp2Writer::writeGeotiffBox(std::ostream* stream, ossimOpjCompressor* compressor)
{
   bool result = false;
   
   if ( theInputConnection.valid() && stream && compressor )
   {
      ossimRefPtr<ossimImageGeometry> geom = theInputConnection->getImageGeometry();
      if ( geom.valid() )
      {
         //---
         // Make a temp file.  No means currently write a tiff straight to
         // memory.
         //---
         ossimFilename tmpFile = theFilename.fileNoExtension();
         tmpFile += "-tmp.tif";
         
         // Output rect.
         ossimIrect rect = theInputConnection->getBoundingRect();
         
         result = compressor->writeGeotiffBox(stream, geom.get(), rect, tmpFile, getPixelType());
      }
   }

   return result;
   
} // End: ossimKakaduJp2Writer::writeGeotffBox
예제 #3
0
void TextureCube::setSubImage(CubeFace cf, int level, int x, int y, int w, int h, TextureFormat f, PixelType t, const Buffer::Parameters &s, const Buffer &pixels)
{
    bindToTextureUnit();
    pixels.bind(GL_PIXEL_UNPACK_BUFFER);
    s.set();
    glTexSubImage2D(getCubeFace(cf), level, x, y, w, h, getTextureFormat(f), getPixelType(t), pixels.data(0));
    s.unset();
    pixels.unbind(GL_PIXEL_UNPACK_BUFFER);
    assert(FrameBuffer::getError() == GL_NO_ERROR);
}
예제 #4
0
void Texture3D::setSubImage(int level, int x, int y, int z, int w, int h, int d, TextureFormat f, PixelType t, const Buffer::Parameters &s, const Buffer &pixels)
{
    bindToTextureUnit();
    pixels.bind(GL_PIXEL_UNPACK_BUFFER);
    s.set();
    glTexSubImage3D(GL_TEXTURE_3D, level, x, y, z, w, h, d, getTextureFormat(f), getPixelType(t), pixels.data(0));
    s.unset();
    pixels.unbind(GL_PIXEL_UNPACK_BUFFER);
    assert(FrameBuffer::getError() == GL_NO_ERROR);
}
예제 #5
0
bool ossimOpjJp2Writer::writeGmlBox(std::ostream* stream, ossimOpjCompressor* compressor)
{
   bool result = false;
   
   if ( theInputConnection.valid() && stream && compressor )
   {
      ossimRefPtr<ossimImageGeometry> geom = theInputConnection->getImageGeometry();
      if ( geom.valid() )
      {
         // Output rect.
         ossimIrect rect = theInputConnection->getBoundingRect();
         
         result = compressor->writeGmlBox(stream, geom.get(), rect, getPixelType());
      }
   }

   return result;
   
} // End: ossimKakaduJp2Writer::writeGmlBox
예제 #6
0
파일: Texture2D.cpp 프로젝트: qqdiguo/ork
void Texture2D::init(int w, int h, TextureInternalFormat tf, TextureFormat f, PixelType t,
    const Parameters &params, const Buffer::Parameters &s, const Buffer &pixels)
{
    Texture::init(tf, params);

    this->w = w;
    this->h = h;

    pixels.bind(GL_PIXEL_UNPACK_BUFFER);

    if (isCompressed() && s.compressedSize() > 0) {
        glCompressedTexImage2D(textureTarget, 0, getTextureInternalFormat(internalFormat), w, h, 0, s.compressedSize(), pixels.data(0));
    } else {
        s.set();
        glTexImage2D(textureTarget, 0, getTextureInternalFormat(internalFormat), w, h, 0, getTextureFormat(f), getPixelType(t), pixels.data(0));
        s.unset();
    }
    pixels.unbind(GL_PIXEL_UNPACK_BUFFER);

    generateMipMap();

    if (FrameBuffer::getError() != 0) {
        throw exception();
    }
}
예제 #7
0
파일: Texture2D.cpp 프로젝트: qqdiguo/ork
void Texture2D::setImage(int w, int h, TextureFormat f, PixelType t, const Buffer &pixels)
{
    this->w = w;
    this->h = h;
    bindToTextureUnit();
    pixels.bind(GL_PIXEL_UNPACK_BUFFER);
    glTexImage2D(textureTarget, 0, getTextureInternalFormat(internalFormat), w, h, 0, getTextureFormat(f), getPixelType(t), pixels.data(0));
    pixels.unbind(GL_PIXEL_UNPACK_BUFFER);
    generateMipMap();

    assert(FrameBuffer::getError() == GL_NO_ERROR);
}
예제 #8
0
void TextureCube::init(int w, int h, TextureInternalFormat tf, TextureFormat f, PixelType t,
    const Parameters &params, Buffer::Parameters s[6], ptr<Buffer> pixels[6])
{
    Texture::init(tf, params);
    this->w = w;
    this->h = h;

    const GLenum FACES[6] = {
        GL_TEXTURE_CUBE_MAP_POSITIVE_X,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
    };
    if (isCompressed()) {
        for (int i = 0; i < 6; ++i) {
            pixels[i]->bind(GL_PIXEL_UNPACK_BUFFER);
            if (s[i].compressedSize() > 0) {
                glCompressedTexImage2D(FACES[i], 0, getTextureInternalFormat(internalFormat), w, h, 0, s[i].compressedSize(), pixels[i]->data(0));
            } else {
                s[i].set();
                glTexImage2D(FACES[i], 0, getTextureInternalFormat(internalFormat), w, h, 0, getTextureFormat(f), getPixelType(t), pixels[i]->data(0));
                s[i].unset();
            }
            pixels[i]->unbind(GL_PIXEL_UNPACK_BUFFER);
        }
    } else {
        for (int i = 0; i < 6; ++i) {
            pixels[i]->bind(GL_PIXEL_UNPACK_BUFFER);
            s[i].set();
            glTexImage2D(FACES[i], 0, getTextureInternalFormat(internalFormat), w, h, 0, getTextureFormat(f), getPixelType(t), pixels[i]->data(0));
            s[i].unset();
            pixels[i]->unbind(GL_PIXEL_UNPACK_BUFFER);
        }
    }

    generateMipMap();

    if (FrameBuffer::getError() != 0) {
        throw exception();
    }
}
예제 #9
0
void Texture::initialize(const PackedFrameDescription &description, const GLvoid * pData) {
	const auto packFormat = description.glPackFormat;
	initialize(description, getAdaptedInternalFormat(packFormat), getPixelFormat(packFormat), getPixelType(packFormat), pData);
}
예제 #10
0
void TextureRectangle::init(int w, int h, TextureInternalFormat tf, TextureFormat f, PixelType t,
    const Parameters &params, const Buffer::Parameters &s, const Buffer &pixels)
{
    Texture::init(tf, params);
    this->w = w;
    this->h = h;

    pixels.bind(GL_PIXEL_UNPACK_BUFFER);
    bool needToGenerateMipmaps = true;
    if (isCompressed() && s.compressedSize() > 0) {
        glCompressedTexImage2D(textureTarget, 0, getTextureInternalFormat(internalFormat), w, h, 0, s.compressedSize(), pixels.data(0));
    } else {
        s.set();
        glTexImage2D(textureTarget, 0, getTextureInternalFormat(internalFormat), w, h, 0, getTextureFormat(f), getPixelType(t), pixels.data(0));
        s.unset();

        GLsizei size = s.compressedSize(); // should work because size is retrieved from file descriptor.
        int pixelSize = getFormatSize(f, t);
        if (size > w * h * pixelSize) {
            // get the other levels from the same buffer
            int offset = w * h * pixelSize;
            int level = 0;
            int wl = w;
            int hl = h;
            while (wl % 2 == 0 && hl % 2 == 0 && size - offset >= (wl * hl / 4) * pixelSize) {
                level += 1;
                wl = wl / 2;
                hl = hl / 2;
                glTexImage2D(textureTarget, level, getTextureInternalFormat(internalFormat), wl, hl, 0, getTextureFormat(f), getPixelType(t), pixels.data(offset));
                offset += wl * hl * pixelSize;
                needToGenerateMipmaps = false;
            }
            this->params.lodMax(clamp(params.lodMax(), GLfloat(0.0f), GLfloat(level)));
        }
    }
    pixels.unbind(GL_PIXEL_UNPACK_BUFFER);

    if (needToGenerateMipmaps) {
        generateMipMap();
    }

    if (FrameBuffer::getError() != 0) {
        throw exception();
    }
}