12#include <jasper/jasper.h>
55 void copyJasperQt(ScanlineFunc scanlinecopier);
56 void copyJasperQtGeneric();
57 void copyScanlineJasperQtRGB(jas_seqent_t **
const jasperRow,
uchar *qtScanLine);
58 void copyScanlineJasperQtRGBA(jas_seqent_t **
const jasperRow,
uchar *qtScanLine);
59 void copyScanlineJasperQtGray(jas_seqent_t **
const jasperRow,
uchar *qtScanLine);
60 void copyScanlineJasperQtGrayA(jas_seqent_t **
const jasperRow,
uchar *qtScanLine);
62 void copyQtJasper(
const ScanlineFuncWrite scanlinecopier);
63 void copyScanlineQtJasperRGB(jas_matrix_t ** jasperRow,
uchar *qtScanLine);
64 void copyScanlineQtJasperRGBA(jas_matrix_t ** jasperRow,
uchar *qtScanLine);
65 void copyScanlineQtJasperColormapRGB(jas_matrix_t ** jasperRow,
uchar *qtScanLine);
66 void copyScanlineQtJasperColormapRGBA(jas_matrix_t ** jasperRow,
uchar *qtScanLine);
67 void copyScanlineQtJasperColormapGrayscale(jas_matrix_t ** jasperRow,
uchar *qtScanLine);
68 void copyScanlineQtJasperColormapGrayscaleA(jas_matrix_t ** jasperRow,
uchar *qtScanLine);
70 bool attemptColorspaceChange(
int wantedColorSpace);
71 bool createJasperMatrix(jas_matrix_t **&
matrix);
72 bool freeJasperMatrix(jas_matrix_t **
matrix);
73 void printColorSpaceError();
74 jas_image_cmptparm_t createComponentMetadata(
const int width,
const int height);
76 jas_image_t *newGrayscaleImage(
const int width,
const int height,
bool alpha);
77 bool decodeColorSpace(
int clrspc,
QString &family,
QString &specific);
78 void printMetadata(jas_image_t *
image);
92 jas_image_t *jasper_image;
95 int jasComponentPrecicion[4];
96 int computedComponentWidth ;
97 int computedComponentHeight;
98 int computedComponentHorizontalSubsampling;
99 int computedComponentVerticalSubsampling;
100 int jasperColorspaceFamily;
103 int colorComponentMapping[4];
108 : writeQuality(100), subType(
"jp2"), q_ptr(q_ptr)
172 bool bCanRead =
false;
256 const int quality =
value.toInt(&
ok);
258 d->writeQuality = quality;
264 d->subType = subTypeCandidate;
301#if JAS_VERSION_MAJOR < 3
304 qDebug(
"Jasper Library initialization failed");
308#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
312 jas_conf_set_max_mem_usage(128 * 1024 * 1024);
314 if (jas_init_library()) {
316 qDebug(
"Jasper library initialization failed");
318 if (jas_init_thread()) {
319 jas_cleanup_library();
321 qDebug(
"Jasper thread initialization failed");
328#if JAS_VERSION_MAJOR < 3
333 if (jas_cleanup_thread()) {
334 qDebug(
"Jasper thread cleanup failed");
336 if (jas_cleanup_library()) {
337 qDebug(
"Jasper library cleanup failed");
369 jas_stream_t *
imageData = jas_stream_memopen(fileContents.
data(),
370 fileContents.
size());
374 qDebug(
"Jasper library can't decode Jpeg2000 image data");
380 qtWidth = jas_image_width(jasper_image);
381 qtHeight = jas_image_height(jasper_image);
382 jasNumComponents = jas_image_numcmpts(jasper_image);
383 jasperColorspaceFamily = jas_clrspc_fam(jas_image_clrspc(jasper_image));
385 bool needColorspaceChange =
false;
386 if (jasperColorspaceFamily != JAS_CLRSPC_FAM_RGB &&
387 jasperColorspaceFamily != JAS_CLRSPC_FAM_GRAY)
388 needColorspaceChange =
true;
392 for (
c = 0;
c < jasNumComponents; ++
c) {
393 jasComponentPrecicion[
c] = jas_image_cmptprec(jasper_image,
c);
396 if (jasComponentPrecicion[
c] > 8 || jasComponentPrecicion[
c] < 8)
397 needColorspaceChange =
true;
400 if (jas_image_cmpthstep(jasper_image,
c) != 1 ||
401 jas_image_cmptvstep(jasper_image,
c) != 1)
402 needColorspaceChange =
true;
405 if (jas_image_cmptsgnd(jasper_image,
c) != 0)
406 needColorspaceChange =
true;
417 bool decodeOk =
true;
418 if (needColorspaceChange)
419 decodeOk = attemptColorspaceChange(JAS_CLRSPC_SRGB);
422 printColorSpaceError();
427 qtWidth = jas_image_width(jasper_image);
428 qtHeight = jas_image_height(jasper_image);
429 jasNumComponents = jas_image_numcmpts(jasper_image);
430 jasperColorspaceFamily = jas_clrspc_fam(jas_image_clrspc(jasper_image));
431 for (
c = 0;
c < jasNumComponents; ++
c) {
432 jasComponentPrecicion[
c] = jas_image_cmptprec(jasper_image,
c);
435 if (jasperColorspaceFamily != JAS_CLRSPC_FAM_RGB &&
436 jasperColorspaceFamily != JAS_CLRSPC_FAM_GRAY) {
437 qDebug(
"The Qt JPEG 2000 reader was unable to convert colorspace to RGB or grayscale");
443 bool oddComponentSubsampling =
false;
444 for (
c = 0;
c < jasNumComponents; ++
c) {
445 if (jas_image_cmpthstep(jasper_image,
c) != 1 ||
446 jas_image_cmptvstep(jasper_image,
c) != 1) {
447 oddComponentSubsampling =
true;
451 if (oddComponentSubsampling) {
454 computedComponentWidth = jas_image_cmptwidth(jasper_image, 0);
455 computedComponentHeight = jas_image_cmptheight(jasper_image, 0);
456 computedComponentHorizontalSubsampling = jas_image_cmpthstep(jasper_image, 0);
457 computedComponentVerticalSubsampling = jas_image_cmptvstep(jasper_image, 0);
459 for (
c = 1;
c < jasNumComponents; ++
c) {
460 if (computedComponentWidth != jas_image_cmptwidth(jasper_image,
c) ||
461 computedComponentWidth != jas_image_cmptwidth(jasper_image,
c) ||
462 computedComponentHorizontalSubsampling != jas_image_cmpthstep(jasper_image,
c) ||
463 computedComponentVerticalSubsampling != jas_image_cmptvstep(jasper_image,
c)) {
464 qDebug(
"The Qt JPEG 2000 reader does not support images where "
465 "component geometry differs from image geometry");
469 qtWidth = computedComponentWidth * computedComponentHorizontalSubsampling;
470 qtHeight = computedComponentHeight * computedComponentVerticalSubsampling;
474 for (
c = 0;
c < jasNumComponents; ++
c) {
476 if (jasComponentPrecicion[
c]>8 || jasComponentPrecicion[
c]<8) {
477 qDebug(
"The Qt JPEG 2000 reader does not support components with "
483 if (oddComponentSubsampling) {
484 qDebug(
"The Qt JPEG 2000 reader does not support components with "
485 "a subsampling factor != 1 (yet)");
490 if (jas_image_cmptsgnd(jasper_image,
c) != 0) {
491 qDebug(
"Qt JPEG 2000 reader does not support signed components");
497 if (!oddComponentSubsampling)
498 if (jas_image_cmpttlx(jasper_image,
c) != 0 ||
499 jas_image_cmpttly(jasper_image,
c) != 0 ||
500 jas_image_cmptbrx(jasper_image,
c) != jas_image_brx(jasper_image) ||
501 jas_image_cmptbry(jasper_image,
c) != jas_image_bry(jasper_image) ||
502 jas_image_cmptwidth (jasper_image,
c) != jas_image_width (jasper_image) ||
503 jas_image_cmptheight(jasper_image,
c) != jas_image_height(jasper_image )) {
504 qDebug(
"The Qt JPEG 2000 reader does not support images where "
505 "component geometry differs from image geometry");
506 printMetadata(jasper_image);
519 jasperColorspaceFamily = jas_clrspc_fam(jas_image_clrspc(jasper_image));
520 if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB) {
521 if (jasNumComponents > 4)
522 qDebug(
"JPEG 2000 reader expected 3 or 4 components, got %d",
526 colorComponentMapping[0] = jas_image_getcmptbytype(jasper_image,
528 colorComponentMapping[1] = jas_image_getcmptbytype(jasper_image,
530 colorComponentMapping[2] = jas_image_getcmptbytype(jasper_image,
533 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY) {
534 if (jasNumComponents > 2)
535 qDebug(
"JPEG 2000 reader expected 1 or 2 components, got %d",
537 colorComponentMapping[0] = jas_image_getcmptbytype(jasper_image,
538 JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y));
541 printColorSpaceError();
548 const int posibleAlphaComponent1 = 3;
549 const int posibleAlphaComponent2 = 48;
551 if (jasNumComponents == qtNumComponents + 1) {
552 colorComponentMapping[qtNumComponents] = jas_image_getcmptbytype(jasper_image, posibleAlphaComponent1);
553 if (colorComponentMapping[qtNumComponents] < 0) {
554 colorComponentMapping[qtNumComponents] = jas_image_getcmptbytype(jasper_image, posibleAlphaComponent2);
556 if (colorComponentMapping[qtNumComponents] > 0) {
563 for (
c = 0;
c < qtNumComponents; ++
c) {
564 if (colorComponentMapping[
c] < 0) {
565 qDebug(
"JPEG 2000 reader missing a color component");
572 if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB)
574 else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY)
580 if (oddComponentSubsampling) {
583 copyJasperQtGeneric();
584 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB) {
586 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtRGBA);
588 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtRGB);
589 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY) {
591 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtGrayA);
593 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtGray);
604void Jpeg2000JasperReader::copyJasperQtGeneric()
607 jas_matrix_t **jasperMatrix;
608 jas_seqent_t **jasperRow;
609 createJasperMatrix(jasperMatrix);
610 jasperRow = (jas_seqent_t**)malloc(jasNumComponents *
sizeof(jas_seqent_t *));
614 for (
int componentY = 0; componentY < computedComponentHeight; ++componentY) {
615 for (
int c = 0;
c < jasNumComponents; ++
c) {
616 jas_image_readcmpt(jasper_image, colorComponentMapping[
c], 0,
617 componentY, computedComponentWidth, 1,
619 jasperRow[
c] = jas_matrix_getref(jasperMatrix[
c], 0, 0);
621 for (
int verticalSubsample = 0;
622 verticalSubsample < computedComponentVerticalSubsampling;
623 ++verticalSubsample) {
625 QRgb *scanLineQRgb =
reinterpret_cast<QRgb *
>(scanLineUchar);
626 for (
int componentX = 0; componentX < computedComponentWidth;
628 for (
int horizontalSubsample = 0;
629 horizontalSubsample <
630 computedComponentHorizontalSubsampling;
631 ++horizontalSubsample) {
632 if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB) {
634 *scanLineQRgb++ = (jasperRow[3][componentX] << 24) |
635 (jasperRow[0][componentX] << 16) |
636 (jasperRow[1][componentX] << 8) |
637 jasperRow[2][componentX];
639 *scanLineQRgb++ = (jasperRow[0][componentX] << 16) |
640 (jasperRow[1][componentX] << 8) |
641 jasperRow[2][componentX];
643 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY) {
645 *scanLineQRgb++ = (jasperRow[1][componentX] << 24) |
646 (jasperRow[0][componentX] << 16) |
647 (jasperRow[0][componentX] << 8) |
648 jasperRow[0][componentX];
650 *scanLineUchar++ = jasperRow[0][componentX];
665void Jpeg2000JasperReader::copyJasperQt(
const ScanlineFunc scanlineCopier)
668 jas_matrix_t **jasperMatrix;
669 jas_seqent_t **jasperRow;
671 createJasperMatrix(jasperMatrix);
672 jasperRow = (jas_seqent_t**)malloc(jasNumComponents *
sizeof(jas_seqent_t *));
675 for (
int scanline = 0; scanline < qtHeight; ++scanline) {
676 for (
int c = 0;
c < jasNumComponents; ++
c) {
677 jas_image_readcmpt(jasper_image, colorComponentMapping[
c], 0,
678 scanline, qtWidth, 1, jasperMatrix[
c]);
679 jasperRow[
c] = jas_matrix_getref(jasperMatrix[
c], 0, 0);
681 (this->*scanlineCopier)(jasperRow, qtImage.
scanLine(scanline));
684 freeJasperMatrix(jasperMatrix);
692void Jpeg2000JasperReader::copyScanlineJasperQtRGB(
693 jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
695 QRgb *scanLine =
reinterpret_cast<QRgb *
>(qtScanLine);
696 for (
int c = 0;
c < qtWidth; ++
c) {
697 *scanLine++ = (0xFF << 24) |
698 (jasperRow[0][
c] << 16) |
699 (jasperRow[1][
c] << 8) |
708void Jpeg2000JasperReader::copyScanlineJasperQtRGBA(jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
710 QRgb *scanLine =
reinterpret_cast<QRgb *
>(qtScanLine);
711 for (
int c = 0;
c < qtWidth; ++
c) {
712 *scanLine++ = (jasperRow[3][
c] << 24) |
713 (jasperRow[0][
c] << 16) |
714 (jasperRow[1][
c] << 8) |
723void Jpeg2000JasperReader::copyScanlineJasperQtGray(jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
725 for (
int c = 0;
c < qtWidth; ++
c) {
727 *qtScanLine++ = jasperRow[0][
c];
738void Jpeg2000JasperReader::copyScanlineJasperQtGrayA(jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
740 QRgb *scanLine =
reinterpret_cast<QRgb *
>(qtScanLine);
741 for (
int c = 0;
c < qtWidth; ++
c) {
742 *scanLine++ = (jasperRow[1][
c] << 24) |
743 (jasperRow[0][
c] << 16) |
744 (jasperRow[0][
c] << 8) |
763 qtHeight = qtImage.
height();
764 qtWidth = qtImage.
width();
765 qtDepth = qtImage.
depth();
768 jasper_image = newRGBAImage(qtWidth, qtHeight, qtImage.
hasAlphaChannel());
773 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperRGBA);
775 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperRGB);
776 }
else if (qtDepth == 8) {
779 jasper_image = newGrayscaleImage(qtWidth, qtHeight, qtImage.
hasAlphaChannel());
784 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscaleA);
786 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscale);
789 jasper_image = newRGBAImage(qtWidth, qtHeight, qtImage.
hasAlphaChannel());
794 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapRGBA);
796 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapRGB);
799 qDebug(
"Unable to handle color depth %d", qtDepth);
805 fmtid = jas_image_strtofmt(
const_cast<char*
>(
"jp2"));
808 fmtid = jas_image_strtofmt(
const_cast<char*
>(
"jpc"));
810 const int minQuality = 0;
811 const int maxQuality = 100;
815 if (quality <= minQuality)
816 quality = minQuality;
817 if (quality > maxQuality)
818 quality = maxQuality;
826 const double minRate = 0.001;
832 const double maxRate = 0.3;
836 const double jasperRate = minRate + pow((
double(quality) /
double(maxQuality)), 2) * maxRate;
845 if (quality != maxQuality) {
851 jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
855 jas_image_encode(jasper_image, memory_stream, fmtid,
str);
857 jas_stream_flush(memory_stream);
863 char *
buffer =
reinterpret_cast<char *
>(
reinterpret_cast<jas_stream_memobj_t*
>(memory_stream->obj_)->buf_);
867 jas_stream_close(memory_stream);
868 jas_image_destroy(jasper_image);
878void Jpeg2000JasperReader::copyQtJasper(
const ScanlineFuncWrite scanlinecopier)
881 jas_matrix_t **jasperMatrix;
882 createJasperMatrix(jasperMatrix);
884 for (
int scanline = 0; scanline < qtHeight; ++scanline) {
885 (this->*scanlinecopier)(jasperMatrix, qtImage.
scanLine(scanline));
888 for (
int c = 0;
c < jasNumComponents; ++
c)
889 jas_image_writecmpt(jasper_image,
c, 0, scanline, qtWidth, 1,
892 freeJasperMatrix(jasperMatrix);
898void Jpeg2000JasperReader::copyScanlineQtJasperRGB(jas_matrix_t ** jasperRow,
901 QRgb *scanLineBuffer =
reinterpret_cast<QRgb *
>(qtScanLine);
902 for (
int col = 0; col < qtWidth; ++col) {
903 jas_matrix_set(jasperRow[0], 0, col, (*scanLineBuffer & 0xFF0000) >> 16);
904 jas_matrix_set(jasperRow[1], 0, col, (*scanLineBuffer & 0x00FF00) >> 8);
905 jas_matrix_set(jasperRow[2], 0, col, *scanLineBuffer & 0x0000FF);
913void Jpeg2000JasperReader::copyScanlineQtJasperRGBA(jas_matrix_t ** jasperRow,
916 QRgb *scanLineBuffer =
reinterpret_cast<QRgb *
>(qtScanLine);
917 for (
int col = 0; col < qtWidth; ++col) {
918 jas_matrix_set(jasperRow[3], 0, col, (*scanLineBuffer & 0xFF000000) >> 24);
919 jas_matrix_set(jasperRow[0], 0, col, (*scanLineBuffer & 0x00FF0000) >> 16);
920 jas_matrix_set(jasperRow[1], 0, col, (*scanLineBuffer & 0x0000FF00) >> 8);
921 jas_matrix_set(jasperRow[2], 0, col, *scanLineBuffer & 0x000000FF);
929void Jpeg2000JasperReader::copyScanlineQtJasperColormapRGB(jas_matrix_t ** jasperRow,
932 for (
int col = 0; col < qtWidth; ++col) {
934 jas_matrix_set(jasperRow[0], 0, col,
qRed(
color));
935 jas_matrix_set(jasperRow[1], 0, col,
qGreen(
color));
936 jas_matrix_set(jasperRow[2], 0, col,
qBlue(
color));
944void Jpeg2000JasperReader::copyScanlineQtJasperColormapRGBA(jas_matrix_t ** jasperRow,
947 for (
int col = 0; col < qtWidth; ++col) {
949 jas_matrix_set(jasperRow[0], 0, col,
qRed(
color));
950 jas_matrix_set(jasperRow[1], 0, col,
qGreen(
color));
951 jas_matrix_set(jasperRow[2], 0, col,
qBlue(
color));
952 jas_matrix_set(jasperRow[3], 0, col,
qAlpha(
color));
960void Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscale(jas_matrix_t ** jasperRow,
963 for (
int col = 0; col < qtWidth; ++col) {
965 jas_matrix_set(jasperRow[0], 0, col,
qGray(
color));
973void Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscaleA(jas_matrix_t ** jasperRow,
976 for (
int col = 0; col < qtWidth; ++col) {
978 jas_matrix_set(jasperRow[0], 0, col,
qGray(
color));
979 jas_matrix_set(jasperRow[1], 0, col,
qAlpha(
color));
989bool Jpeg2000JasperReader::attemptColorspaceChange(
int wantedColorSpace)
992 jas_cmprof_t *outprof;
993 if (!(outprof = jas_cmprof_createfromclrspc(wantedColorSpace)))
996 jas_image_t *newimage;
997 if (!(newimage = jas_image_chclrspc(jasper_image, outprof,
998 JAS_CMXFORM_INTENT_PER))) {
999 jas_cmprof_destroy(outprof);
1002 jas_image_destroy(jasper_image);
1003 jas_cmprof_destroy(outprof);
1004 jasper_image = newimage;
1012jas_image_cmptparm_t Jpeg2000JasperReader::createComponentMetadata(
1015 jas_image_cmptparm_t
param;
1031jas_image_t* Jpeg2000JasperReader::newRGBAImage(
const int width,
1034 jasNumComponents =
alpha ? 4 : 3;
1035 jas_image_cmptparm_t *
params =
new jas_image_cmptparm_t[jasNumComponents];
1037 for (
int c=0;
c < jasNumComponents;
c++)
1039 jas_image_t *newImage = jas_image_create(jasNumComponents,
params,
1047 jas_image_setcmpttype(newImage, 0, JAS_IMAGE_CT_RGB_R);
1048 jas_image_setcmpttype(newImage, 1, JAS_IMAGE_CT_RGB_G);
1049 jas_image_setcmpttype(newImage, 2, JAS_IMAGE_CT_RGB_B);
1064 jas_image_setcmpttype(newImage, 3, JAS_IMAGE_CT_OPACITY);
1073jas_image_t *Jpeg2000JasperReader::newGrayscaleImage(
const int width,
1077 jasNumComponents =
alpha ? 2 : 1;
1079 jas_image_t *newImage = jas_image_create(1, &
param, JAS_CLRSPC_SGRAY);
1083 jas_image_setcmpttype(newImage, 0, JAS_IMAGE_CT_GRAY_Y);
1087 jas_image_setcmpttype(newImage, 1, JAS_IMAGE_CT_OPACITY);
1096bool Jpeg2000JasperReader::createJasperMatrix(jas_matrix_t **&
matrix)
1098 matrix = (jas_matrix_t**)malloc(jasNumComponents *
sizeof(jas_matrix_t *));
1099 for (
int c = 0;
c < jasNumComponents; ++
c)
1100 matrix[
c] = jas_matrix_create(1, qtWidth);
1109bool Jpeg2000JasperReader::freeJasperMatrix(jas_matrix_t **
matrix)
1111 for (
int c = 0;
c < jasNumComponents; ++
c)
1112 jas_matrix_destroy(
matrix[
c]);
1120void Jpeg2000JasperReader::printColorSpaceError()
1122 QString colorspaceFamily, colorspaceSpecific;
1123 decodeColorSpace(jas_image_clrspc(jasper_image), colorspaceFamily,
1124 colorspaceSpecific);
1125 qDebug(
"Jpeg2000 decoder is not able to handle color space %s - %s",
1131bool Jpeg2000JasperReader::decodeColorSpace(
int clrspc,
QString &family,
1134 int fam = jas_clrspc_fam(clrspc);
1135 int mbr = jas_clrspc_mbr(clrspc);
1138 case 0: family =
QLatin1String(
"JAS_CLRSPC_FAM_UNKNOWN");
break;
1139 case 1: family =
QLatin1String(
"JAS_CLRSPC_FAM_XYZ");
break;
1140 case 2: family =
QLatin1String(
"JAS_CLRSPC_FAM_LAB");
break;
1141 case 3: family =
QLatin1String(
"JAS_CLRSPC_FAM_GRAY");
break;
1142 case 4: family =
QLatin1String(
"JAS_CLRSPC_FAM_RGB");
break;
1143 case 5: family =
QLatin1String(
"JAS_CLRSPC_FAM_YCBCR");
break;
1150 case 1: specific =
QLatin1String(
"JAS_CLRSPC_CIEXYZ");
break;
1151 case 2: specific =
QLatin1String(
"JAS_CLRSPC_CIELAB");
break;
1152 case 3: specific =
QLatin1String(
"JAS_CLRSPC_SGRAY");
break;
1154 case 5: specific =
QLatin1String(
"JAS_CLRSPC_SYCBCR");
break;
1160 case 3: specific =
QLatin1String(
"JAS_CLRSPC_GENGRAY");
break;
1161 case 4: specific =
QLatin1String(
"JAS_CLRSPC_GENRGB");
break;
1162 case 5: specific =
QLatin1String(
"JAS_CLRSPC_GENYCBCR");
break;
1174void Jpeg2000JasperReader::printMetadata(jas_image_t *
image)
1178 qDebug(
"Image width: %ld",
long(jas_image_width(
image)));
1179 qDebug(
"Image height: %ld",
long(jas_image_height(
image)));
1180 qDebug(
"Coordinates on reference grid: (%ld,%ld) (%ld,%ld)",
1181 long(jas_image_tlx(
image)),
long(jas_image_tly(
image)),
1182 long(jas_image_brx(
image)),
long(jas_image_bry(
image)));
1183 qDebug(
"Number of image components: %d", jas_image_numcmpts(
image));
1187 decodeColorSpace(jas_image_clrspc(
image), colorspaceFamily, colorspaceSpecific);
1188 qDebug(
"Color model (space): %d, %s - %s", jas_image_clrspc(
image),
1191 qDebug(
"Component metadata:");
1193 for (
int c = 0; c < static_cast<int>(jas_image_numcmpts(
image)); ++
c) {
1195 qDebug(
" Component type: %ld",
long(jas_image_cmpttype(
image,
c)));
1196 qDebug(
" Width: %ld",
long(jas_image_cmptwidth(
image,
c)));
1197 qDebug(
" Height: %ld",
long(jas_image_cmptheight(
image,
c)));
1198 qDebug(
" Signedness: %d", jas_image_cmptsgnd(
image,
c));
1199 qDebug(
" Precision: %d", jas_image_cmptprec(
image,
c));
1200 qDebug(
" Horizontal subsampling factor: %ld",
long(jas_image_cmpthstep(
image,
c)));
1201 qDebug(
" Vertical subsampling factor: %ld",
long(jas_image_cmptvstep(
image,
c)));
1202 qDebug(
" Coordinates on reference grid: (%ld,%ld) (%ld,%ld)",
1203 long(jas_image_cmpttlx(
image,
c)),
long(jas_image_cmpttly(
image,
c)),
1204 long(jas_image_cmptbrx(
image,
c)),
long(jas_image_cmptbry(
image,
c)));
bool read(QImage *pImage)
Jpeg2000JasperReader(QIODevice *iod, const SubFormat format=Jp2Format)
bool write(const QImage &image, int quality)
Opens the file data and attempts to decode it using the Jasper library.
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
\inmodule QtCore \reentrant
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
qint64 peek(char *data, qint64 maxlen)
ImageOption
This enum describes the different options supported by QImageIOHandler.
static bool allocateImage(QSize size, QImage::Format format, QImage *image)
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
void setFormat(const QByteArray &format)
Sets the format of the QImageIOHandler to format.
static int allocationLimit()
QImage read()
Reads an image from the device.
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
bool allGray() const
Returns true if all the colors in the image are shades of gray (i.e.
QRgb color(int i) const
Returns the color in the color table at index i.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
Format
The following image formats are available in Qt.
QJp2HandlerPrivate(QJp2Handler *q_ptr)
The QJp2Handler class provides support for reading and writing JPEG 2000 image files with the Qt plug...
~QJp2Handler()
Destructor for QJp2Handler.
QJp2Handler()
Constructs an instance of QJp2Handler.
void setOption(ImageOption option, const QVariant &value) override
The JPEG 2000 handler supports two options.
bool write(const QImage &image) override
\reimp
bool read(QImage *image) override
\reimp
bool supportsOption(ImageOption option) const override
This function will return true if option is set to either QImageIOHandler::Quality or QImageIOHandler...
QVariant option(ImageOption option) const override
Get the value associated with option.
bool canRead() const override
\reimp
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Automatic resource handling for a jas_image_t*.
ScopedJasperImage(jas_image_t *&image)
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
Q_CORE_EXPORT char * qstrdup(const char *)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLsizei GLsizei height
GLenum GLuint GLenum GLsizei length
GLenum const GLint * param
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat alpha
static bool hasAlpha(const QImage &image)
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
constexpr int qRed(QRgb rgb)
constexpr int qGreen(QRgb rgb)
constexpr int qGray(int r, int g, int b)
constexpr int qBlue(QRgb rgb)
constexpr int qAlpha(QRgb rgb)
#define qPrintable(string)
QLatin1StringView QLatin1String
Q_CHECK_PTR(a=new int[80])