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;
222 return writer.write(
image,
d->writeQuality);
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)
313 jas_conf_set_max_mem_usage(128 * 1024 * 1024);
315 if (jas_init_library()) {
317 qDebug(
"Jasper library initialization failed");
319 if (jas_init_thread()) {
320 jas_cleanup_library();
322 qDebug(
"Jasper thread initialization failed");
329#if JAS_VERSION_MAJOR < 3
334 if (jas_cleanup_thread()) {
335 qDebug(
"Jasper thread cleanup failed");
337 if (jas_cleanup_library()) {
338 qDebug(
"Jasper library cleanup failed");
370 jas_stream_t *
imageData = jas_stream_memopen(fileContents.data(),
371 fileContents.size());
375 qDebug(
"Jasper library can't decode Jpeg2000 image data");
381 qtWidth = jas_image_width(jasper_image);
382 qtHeight = jas_image_height(jasper_image);
383 jasNumComponents = jas_image_numcmpts(jasper_image);
384 jasperColorspaceFamily = jas_clrspc_fam(jas_image_clrspc(jasper_image));
386 bool needColorspaceChange =
false;
387 if (jasperColorspaceFamily != JAS_CLRSPC_FAM_RGB &&
388 jasperColorspaceFamily != JAS_CLRSPC_FAM_GRAY)
389 needColorspaceChange =
true;
393 for (
c = 0;
c < jasNumComponents; ++
c) {
394 jasComponentPrecicion[
c] = jas_image_cmptprec(jasper_image,
c);
397 if (jasComponentPrecicion[
c] > 8 || jasComponentPrecicion[
c] < 8)
398 needColorspaceChange =
true;
401 if (jas_image_cmpthstep(jasper_image,
c) != 1 ||
402 jas_image_cmptvstep(jasper_image,
c) != 1)
403 needColorspaceChange =
true;
406 if (jas_image_cmptsgnd(jasper_image,
c) != 0)
407 needColorspaceChange =
true;
418 bool decodeOk =
true;
419 if (needColorspaceChange)
420 decodeOk = attemptColorspaceChange(JAS_CLRSPC_SRGB);
423 printColorSpaceError();
428 qtWidth = jas_image_width(jasper_image);
429 qtHeight = jas_image_height(jasper_image);
430 jasNumComponents = jas_image_numcmpts(jasper_image);
431 jasperColorspaceFamily = jas_clrspc_fam(jas_image_clrspc(jasper_image));
432 for (
c = 0;
c < jasNumComponents; ++
c) {
433 jasComponentPrecicion[
c] = jas_image_cmptprec(jasper_image,
c);
436 if (jasperColorspaceFamily != JAS_CLRSPC_FAM_RGB &&
437 jasperColorspaceFamily != JAS_CLRSPC_FAM_GRAY) {
438 qDebug(
"The Qt JPEG 2000 reader was unable to convert colorspace to RGB or grayscale");
444 bool oddComponentSubsampling =
false;
445 for (
c = 0;
c < jasNumComponents; ++
c) {
446 if (jas_image_cmpthstep(jasper_image,
c) != 1 ||
447 jas_image_cmptvstep(jasper_image,
c) != 1) {
448 oddComponentSubsampling =
true;
452 if (oddComponentSubsampling) {
455 computedComponentWidth = jas_image_cmptwidth(jasper_image, 0);
456 computedComponentHeight = jas_image_cmptheight(jasper_image, 0);
457 computedComponentHorizontalSubsampling = jas_image_cmpthstep(jasper_image, 0);
458 computedComponentVerticalSubsampling = jas_image_cmptvstep(jasper_image, 0);
460 for (
c = 1;
c < jasNumComponents; ++
c) {
461 if (computedComponentWidth != jas_image_cmptwidth(jasper_image,
c) ||
462 computedComponentWidth != jas_image_cmptwidth(jasper_image,
c) ||
463 computedComponentHorizontalSubsampling != jas_image_cmpthstep(jasper_image,
c) ||
464 computedComponentVerticalSubsampling != jas_image_cmptvstep(jasper_image,
c)) {
465 qDebug(
"The Qt JPEG 2000 reader does not support images where "
466 "component geometry differs from image geometry");
470 qtWidth = computedComponentWidth * computedComponentHorizontalSubsampling;
471 qtHeight = computedComponentHeight * computedComponentVerticalSubsampling;
475 for (
c = 0;
c < jasNumComponents; ++
c) {
477 if (jasComponentPrecicion[
c]>8 || jasComponentPrecicion[
c]<8) {
478 qDebug(
"The Qt JPEG 2000 reader does not support components with "
484 if (oddComponentSubsampling) {
485 qDebug(
"The Qt JPEG 2000 reader does not support components with "
486 "a subsampling factor != 1 (yet)");
491 if (jas_image_cmptsgnd(jasper_image,
c) != 0) {
492 qDebug(
"Qt JPEG 2000 reader does not support signed components");
498 if (!oddComponentSubsampling)
499 if (jas_image_cmpttlx(jasper_image,
c) != 0 ||
500 jas_image_cmpttly(jasper_image,
c) != 0 ||
501 jas_image_cmptbrx(jasper_image,
c) != jas_image_brx(jasper_image) ||
502 jas_image_cmptbry(jasper_image,
c) != jas_image_bry(jasper_image) ||
503 jas_image_cmptwidth (jasper_image,
c) != jas_image_width (jasper_image) ||
504 jas_image_cmptheight(jasper_image,
c) != jas_image_height(jasper_image )) {
505 qDebug(
"The Qt JPEG 2000 reader does not support images where "
506 "component geometry differs from image geometry");
507 printMetadata(jasper_image);
520 jasperColorspaceFamily = jas_clrspc_fam(jas_image_clrspc(jasper_image));
521 if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB) {
522 if (jasNumComponents > 4)
523 qDebug(
"JPEG 2000 reader expected 3 or 4 components, got %d",
527 colorComponentMapping[0] = jas_image_getcmptbytype(jasper_image,
529 colorComponentMapping[1] = jas_image_getcmptbytype(jasper_image,
531 colorComponentMapping[2] = jas_image_getcmptbytype(jasper_image,
534 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY) {
535 if (jasNumComponents > 2)
536 qDebug(
"JPEG 2000 reader expected 1 or 2 components, got %d",
538 colorComponentMapping[0] = jas_image_getcmptbytype(jasper_image,
539 JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y));
542 printColorSpaceError();
549 const int posibleAlphaComponent1 = 3;
550 const int posibleAlphaComponent2 = 48;
552 if (jasNumComponents == qtNumComponents + 1) {
553 colorComponentMapping[qtNumComponents] = jas_image_getcmptbytype(jasper_image, posibleAlphaComponent1);
554 if (colorComponentMapping[qtNumComponents] < 0) {
555 colorComponentMapping[qtNumComponents] = jas_image_getcmptbytype(jasper_image, posibleAlphaComponent2);
557 if (colorComponentMapping[qtNumComponents] > 0) {
564 for (
c = 0;
c < qtNumComponents; ++
c) {
565 if (colorComponentMapping[
c] < 0) {
566 qDebug(
"JPEG 2000 reader missing a color component");
573 if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB)
575 else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY)
581 if (oddComponentSubsampling) {
584 copyJasperQtGeneric();
585 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB) {
587 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtRGBA);
589 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtRGB);
590 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY) {
592 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtGrayA);
594 copyJasperQt(&Jpeg2000JasperReader::copyScanlineJasperQtGray);
605void Jpeg2000JasperReader::copyJasperQtGeneric()
608 jas_matrix_t **jasperMatrix;
609 jas_seqent_t **jasperRow;
610 createJasperMatrix(jasperMatrix);
611 jasperRow = (jas_seqent_t**)malloc(jasNumComponents *
sizeof(jas_seqent_t *));
615 for (
int componentY = 0; componentY < computedComponentHeight; ++componentY) {
616 for (
int c = 0;
c < jasNumComponents; ++
c) {
617 jas_image_readcmpt(jasper_image, colorComponentMapping[
c], 0,
618 componentY, computedComponentWidth, 1,
620 jasperRow[
c] = jas_matrix_getref(jasperMatrix[
c], 0, 0);
622 for (
int verticalSubsample = 0;
623 verticalSubsample < computedComponentVerticalSubsampling;
624 ++verticalSubsample) {
626 QRgb *scanLineQRgb =
reinterpret_cast<QRgb *
>(scanLineUchar);
627 for (
int componentX = 0; componentX < computedComponentWidth;
629 for (
int horizontalSubsample = 0;
630 horizontalSubsample <
631 computedComponentHorizontalSubsampling;
632 ++horizontalSubsample) {
633 if (jasperColorspaceFamily == JAS_CLRSPC_FAM_RGB) {
635 *scanLineQRgb++ = (jasperRow[3][componentX] << 24) |
636 (jasperRow[0][componentX] << 16) |
637 (jasperRow[1][componentX] << 8) |
638 jasperRow[2][componentX];
640 *scanLineQRgb++ = (jasperRow[0][componentX] << 16) |
641 (jasperRow[1][componentX] << 8) |
642 jasperRow[2][componentX];
644 }
else if (jasperColorspaceFamily == JAS_CLRSPC_FAM_GRAY) {
646 *scanLineQRgb++ = (jasperRow[1][componentX] << 24) |
647 (jasperRow[0][componentX] << 16) |
648 (jasperRow[0][componentX] << 8) |
649 jasperRow[0][componentX];
651 *scanLineUchar++ = jasperRow[0][componentX];
666void Jpeg2000JasperReader::copyJasperQt(
const ScanlineFunc scanlineCopier)
669 jas_matrix_t **jasperMatrix;
670 jas_seqent_t **jasperRow;
672 createJasperMatrix(jasperMatrix);
673 jasperRow = (jas_seqent_t**)malloc(jasNumComponents *
sizeof(jas_seqent_t *));
676 for (
int scanline = 0; scanline < qtHeight; ++scanline) {
677 for (
int c = 0;
c < jasNumComponents; ++
c) {
678 jas_image_readcmpt(jasper_image, colorComponentMapping[
c], 0,
679 scanline, qtWidth, 1, jasperMatrix[
c]);
680 jasperRow[
c] = jas_matrix_getref(jasperMatrix[
c], 0, 0);
682 (this->*scanlineCopier)(jasperRow, qtImage.
scanLine(scanline));
685 freeJasperMatrix(jasperMatrix);
693void Jpeg2000JasperReader::copyScanlineJasperQtRGB(
694 jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
696 QRgb *scanLine =
reinterpret_cast<QRgb *
>(qtScanLine);
697 for (
int c = 0;
c < qtWidth; ++
c) {
698 *scanLine++ = (0xFF << 24) |
699 (jasperRow[0][
c] << 16) |
700 (jasperRow[1][
c] << 8) |
709void Jpeg2000JasperReader::copyScanlineJasperQtRGBA(jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
711 QRgb *scanLine =
reinterpret_cast<QRgb *
>(qtScanLine);
712 for (
int c = 0;
c < qtWidth; ++
c) {
713 *scanLine++ = (jasperRow[3][
c] << 24) |
714 (jasperRow[0][
c] << 16) |
715 (jasperRow[1][
c] << 8) |
724void Jpeg2000JasperReader::copyScanlineJasperQtGray(jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
726 for (
int c = 0;
c < qtWidth; ++
c) {
728 *qtScanLine++ = jasperRow[0][
c];
739void Jpeg2000JasperReader::copyScanlineJasperQtGrayA(jas_seqent_t **
const jasperRow,
uchar *qtScanLine)
741 QRgb *scanLine =
reinterpret_cast<QRgb *
>(qtScanLine);
742 for (
int c = 0;
c < qtWidth; ++
c) {
743 *scanLine++ = (jasperRow[1][
c] << 24) |
744 (jasperRow[0][
c] << 16) |
745 (jasperRow[0][
c] << 8) |
764 qtHeight = qtImage.
height();
765 qtWidth = qtImage.
width();
766 qtDepth = qtImage.
depth();
769 jasper_image = newRGBAImage(qtWidth, qtHeight, qtImage.
hasAlphaChannel());
774 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperRGBA);
776 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperRGB);
777 }
else if (qtDepth == 8) {
780 jasper_image = newGrayscaleImage(qtWidth, qtHeight, qtImage.
hasAlphaChannel());
785 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscaleA);
787 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscale);
790 jasper_image = newRGBAImage(qtWidth, qtHeight, qtImage.
hasAlphaChannel());
795 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapRGBA);
797 copyQtJasper(&Jpeg2000JasperReader::copyScanlineQtJasperColormapRGB);
800 qDebug(
"Unable to handle color depth %d", qtDepth);
806 fmtid = jas_image_strtofmt(
const_cast<char*
>(
"jp2"));
809 fmtid = jas_image_strtofmt(
const_cast<char*
>(
"jpc"));
811 const int minQuality = 0;
812 const int maxQuality = 100;
816 if (quality <= minQuality)
817 quality = minQuality;
818 if (quality > maxQuality)
819 quality = maxQuality;
827 const double minRate = 0.001;
833 const double maxRate = 0.3;
837 const double jasperRate = minRate + pow((
double(quality) /
double(maxQuality)), 2) * maxRate;
846 if (quality != maxQuality) {
852 jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
855 char *
str =
qstrdup(jasperFormatString.toLatin1().constData());
856 jas_image_encode(jasper_image, memory_stream, fmtid,
str);
858 jas_stream_flush(memory_stream);
864 char *
buffer =
reinterpret_cast<char *
>(
reinterpret_cast<jas_stream_memobj_t*
>(memory_stream->obj_)->buf_);
868 jas_stream_close(memory_stream);
869 jas_image_destroy(jasper_image);
879void Jpeg2000JasperReader::copyQtJasper(
const ScanlineFuncWrite scanlinecopier)
882 jas_matrix_t **jasperMatrix;
883 createJasperMatrix(jasperMatrix);
885 for (
int scanline = 0; scanline < qtHeight; ++scanline) {
886 (this->*scanlinecopier)(jasperMatrix, qtImage.
scanLine(scanline));
889 for (
int c = 0;
c < jasNumComponents; ++
c)
890 jas_image_writecmpt(jasper_image,
c, 0, scanline, qtWidth, 1,
893 freeJasperMatrix(jasperMatrix);
899void Jpeg2000JasperReader::copyScanlineQtJasperRGB(jas_matrix_t ** jasperRow,
902 QRgb *scanLineBuffer =
reinterpret_cast<QRgb *
>(qtScanLine);
903 for (
int col = 0; col < qtWidth; ++col) {
904 jas_matrix_set(jasperRow[0], 0, col, (*scanLineBuffer & 0xFF0000) >> 16);
905 jas_matrix_set(jasperRow[1], 0, col, (*scanLineBuffer & 0x00FF00) >> 8);
906 jas_matrix_set(jasperRow[2], 0, col, *scanLineBuffer & 0x0000FF);
914void Jpeg2000JasperReader::copyScanlineQtJasperRGBA(jas_matrix_t ** jasperRow,
917 QRgb *scanLineBuffer =
reinterpret_cast<QRgb *
>(qtScanLine);
918 for (
int col = 0; col < qtWidth; ++col) {
919 jas_matrix_set(jasperRow[3], 0, col, (*scanLineBuffer & 0xFF000000) >> 24);
920 jas_matrix_set(jasperRow[0], 0, col, (*scanLineBuffer & 0x00FF0000) >> 16);
921 jas_matrix_set(jasperRow[1], 0, col, (*scanLineBuffer & 0x0000FF00) >> 8);
922 jas_matrix_set(jasperRow[2], 0, col, *scanLineBuffer & 0x000000FF);
930void Jpeg2000JasperReader::copyScanlineQtJasperColormapRGB(jas_matrix_t ** jasperRow,
933 for (
int col = 0; col < qtWidth; ++col) {
935 jas_matrix_set(jasperRow[0], 0, col,
qRed(
color));
936 jas_matrix_set(jasperRow[1], 0, col,
qGreen(
color));
937 jas_matrix_set(jasperRow[2], 0, col,
qBlue(
color));
945void Jpeg2000JasperReader::copyScanlineQtJasperColormapRGBA(jas_matrix_t ** jasperRow,
948 for (
int col = 0; col < qtWidth; ++col) {
950 jas_matrix_set(jasperRow[0], 0, col,
qRed(
color));
951 jas_matrix_set(jasperRow[1], 0, col,
qGreen(
color));
952 jas_matrix_set(jasperRow[2], 0, col,
qBlue(
color));
953 jas_matrix_set(jasperRow[3], 0, col,
qAlpha(
color));
961void Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscale(jas_matrix_t ** jasperRow,
964 for (
int col = 0; col < qtWidth; ++col) {
966 jas_matrix_set(jasperRow[0], 0, col,
qGray(
color));
974void Jpeg2000JasperReader::copyScanlineQtJasperColormapGrayscaleA(jas_matrix_t ** jasperRow,
977 for (
int col = 0; col < qtWidth; ++col) {
979 jas_matrix_set(jasperRow[0], 0, col,
qGray(
color));
980 jas_matrix_set(jasperRow[1], 0, col,
qAlpha(
color));
990bool Jpeg2000JasperReader::attemptColorspaceChange(
int wantedColorSpace)
993 jas_cmprof_t *outprof;
994 if (!(outprof = jas_cmprof_createfromclrspc(wantedColorSpace)))
997 jas_image_t *newimage;
998 if (!(newimage = jas_image_chclrspc(jasper_image, outprof,
999 JAS_CMXFORM_INTENT_PER))) {
1000 jas_cmprof_destroy(outprof);
1003 jas_image_destroy(jasper_image);
1004 jas_cmprof_destroy(outprof);
1005 jasper_image = newimage;
1013jas_image_cmptparm_t Jpeg2000JasperReader::createComponentMetadata(
1016 jas_image_cmptparm_t
param;
1032jas_image_t* Jpeg2000JasperReader::newRGBAImage(
const int width,
1035 jasNumComponents =
alpha ? 4 : 3;
1036 jas_image_cmptparm_t *
params =
new jas_image_cmptparm_t[jasNumComponents];
1038 for (
int c=0;
c < jasNumComponents;
c++)
1040 jas_image_t *newImage = jas_image_create(jasNumComponents,
params,
1048 jas_image_setcmpttype(newImage, 0, JAS_IMAGE_CT_RGB_R);
1049 jas_image_setcmpttype(newImage, 1, JAS_IMAGE_CT_RGB_G);
1050 jas_image_setcmpttype(newImage, 2, JAS_IMAGE_CT_RGB_B);
1065 jas_image_setcmpttype(newImage, 3, JAS_IMAGE_CT_OPACITY);
1074jas_image_t *Jpeg2000JasperReader::newGrayscaleImage(
const int width,
1078 jasNumComponents =
alpha ? 2 : 1;
1080 jas_image_t *newImage = jas_image_create(1, &
param, JAS_CLRSPC_SGRAY);
1084 jas_image_setcmpttype(newImage, 0, JAS_IMAGE_CT_GRAY_Y);
1088 jas_image_setcmpttype(newImage, 1, JAS_IMAGE_CT_OPACITY);
1097bool Jpeg2000JasperReader::createJasperMatrix(jas_matrix_t **&
matrix)
1099 matrix = (jas_matrix_t**)malloc(jasNumComponents *
sizeof(jas_matrix_t *));
1100 for (
int c = 0;
c < jasNumComponents; ++
c)
1101 matrix[
c] = jas_matrix_create(1, qtWidth);
1110bool Jpeg2000JasperReader::freeJasperMatrix(jas_matrix_t **
matrix)
1112 for (
int c = 0;
c < jasNumComponents; ++
c)
1113 jas_matrix_destroy(
matrix[
c]);
1121void Jpeg2000JasperReader::printColorSpaceError()
1123 QString colorspaceFamily, colorspaceSpecific;
1124 decodeColorSpace(jas_image_clrspc(jasper_image), colorspaceFamily,
1125 colorspaceSpecific);
1126 qDebug(
"Jpeg2000 decoder is not able to handle color space %s - %s",
1132bool Jpeg2000JasperReader::decodeColorSpace(
int clrspc,
QString &family,
1135 int fam = jas_clrspc_fam(clrspc);
1136 int mbr = jas_clrspc_mbr(clrspc);
1139 case 0: family =
QLatin1String(
"JAS_CLRSPC_FAM_UNKNOWN");
break;
1140 case 1: family =
QLatin1String(
"JAS_CLRSPC_FAM_XYZ");
break;
1141 case 2: family =
QLatin1String(
"JAS_CLRSPC_FAM_LAB");
break;
1142 case 3: family =
QLatin1String(
"JAS_CLRSPC_FAM_GRAY");
break;
1143 case 4: family =
QLatin1String(
"JAS_CLRSPC_FAM_RGB");
break;
1144 case 5: family =
QLatin1String(
"JAS_CLRSPC_FAM_YCBCR");
break;
1151 case 1: specific =
QLatin1String(
"JAS_CLRSPC_CIEXYZ");
break;
1152 case 2: specific =
QLatin1String(
"JAS_CLRSPC_CIELAB");
break;
1153 case 3: specific =
QLatin1String(
"JAS_CLRSPC_SGRAY");
break;
1155 case 5: specific =
QLatin1String(
"JAS_CLRSPC_SYCBCR");
break;
1161 case 3: specific =
QLatin1String(
"JAS_CLRSPC_GENGRAY");
break;
1162 case 4: specific =
QLatin1String(
"JAS_CLRSPC_GENRGB");
break;
1163 case 5: specific =
QLatin1String(
"JAS_CLRSPC_GENYCBCR");
break;
1175void Jpeg2000JasperReader::printMetadata(jas_image_t *
image)
1179 qDebug(
"Image width: %ld",
long(jas_image_width(
image)));
1180 qDebug(
"Image height: %ld",
long(jas_image_height(
image)));
1181 qDebug(
"Coordinates on reference grid: (%ld,%ld) (%ld,%ld)",
1182 long(jas_image_tlx(
image)),
long(jas_image_tly(
image)),
1183 long(jas_image_brx(
image)),
long(jas_image_bry(
image)));
1184 qDebug(
"Number of image components: %d", jas_image_numcmpts(
image));
1188 decodeColorSpace(jas_image_clrspc(
image), colorspaceFamily, colorspaceSpecific);
1189 qDebug(
"Color model (space): %d, %s - %s", jas_image_clrspc(
image),
1192 qDebug(
"Component metadata:");
1194 for (
int c = 0; c < static_cast<int>(jas_image_numcmpts(
image)); ++
c) {
1196 qDebug(
" Component type: %ld",
long(jas_image_cmpttype(
image,
c)));
1197 qDebug(
" Width: %ld",
long(jas_image_cmptwidth(
image,
c)));
1198 qDebug(
" Height: %ld",
long(jas_image_cmptheight(
image,
c)));
1199 qDebug(
" Signedness: %d", jas_image_cmptsgnd(
image,
c));
1200 qDebug(
" Precision: %d", jas_image_cmptprec(
image,
c));
1201 qDebug(
" Horizontal subsampling factor: %ld",
long(jas_image_cmpthstep(
image,
c)));
1202 qDebug(
" Vertical subsampling factor: %ld",
long(jas_image_cmptvstep(
image,
c)));
1203 qDebug(
" Coordinates on reference grid: (%ld,%ld) (%ld,%ld)",
1204 long(jas_image_cmpttlx(
image,
c)),
long(jas_image_cmpttly(
image,
c)),
1205 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.
\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
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)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
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])