void MainWindow::CompressImage()
{
_jpegSize = 0;
_compressedImage = NULL; //!< Memory is allocated by tjCompress2 if _jpegSize == 0
unsigned char *buffer = new unsigned char[_width*_height*COLOR_COMPONENTS]; //!< Contains the uncompressed image
buffer = (unsigned char*) fileContent.constData();
tjhandle _jpegCompressor = tjInitCompress();
tjCompress2(_jpegCompressor, buffer, _width, 0, _height, TJPF_RGB,
&_compressedImage, &_jpegSize, TJSAMP_444, JPEG_QUALITY,TJFLAG_FASTDCT);
tjDestroy(_jpegCompressor);
qDebug() << _jpegSize;
}
void MainWindow::DecompressImage()
{
// int _jpegSize; //!< _jpegSize from above
// unsigned char* _compressedImage; //!< _compressedImage from above
int jpegSubsamp;
unsigned char* buffer;
buffer = new unsigned char[_width*_height*COLOR_COMPONENTS]; //!< will contain the decompressed image
tjhandle _jpegDecompressor = tjInitDecompress();
tjDecompressHeader2(_jpegDecompressor, _compressedImage, _jpegSize, &_width, &_height, &jpegSubsamp);
tjDecompress2(_jpegDecompressor, _compressedImage, _jpegSize, buffer, _width, 0/*pitch*/, _height, TJPF_RGB, TJFLAG_FASTDCT);
tjDestroy(_jpegDecompressor);
qDebug() << _jpegSize;
ui->label->setPixmap(px);
}
void MainWindow::CompressImage()
{
_jpegSize = 0;
_compressedImage = NULL; //!< Memory is allocated by tjCompress2 if _jpegSize == 0
unsigned char *buffer = new unsigned char[_width*_height*COLOR_COMPONENTS]; //!< Contains the uncompressed image
buffer = (unsigned char*) fileContent.constData();
tjhandle _jpegCompressor = tjInitCompress();
tjCompress2(_jpegCompressor, buffer, _width, 0, _height, TJPF_RGB,
&_compressedImage, &_jpegSize, TJSAMP_444, JPEG_QUALITY,TJFLAG_FASTDCT);
tjDestroy(_jpegCompressor);
qDebug() << _jpegSize;
}
void MainWindow::DecompressImage()
{
// int _jpegSize; //!< _jpegSize from above
// unsigned char* _compressedImage; //!< _compressedImage from above
int jpegSubsamp;
unsigned char* buffer;
buffer = new unsigned char[_width*_height*COLOR_COMPONENTS]; //!< will contain the decompressed image
tjhandle _jpegDecompressor = tjInitDecompress();
tjDecompressHeader2(_jpegDecompressor, _compressedImage, _jpegSize, &_width, &_height, &jpegSubsamp);
tjDecompress2(_jpegDecompressor, _compressedImage, _jpegSize, buffer, _width, 0/*pitch*/, _height, TJPF_RGB, TJFLAG_FASTDCT);
tjDestroy(_jpegDecompressor);
qDebug() << _jpegSize;
QPixmap px((const char*)buffer);
ui->label->setPixmap(px);
}
To copy to clipboard, switch view to plain text mode
Bookmarks