3352 Format_ARGB4444_Premultiplied |
3352 Format_ARGB4444_Premultiplied |
3353 */ |
3353 */ |
3354 |
3354 |
3355 |
3355 |
3356 // first index source, second dest |
3356 // first index source, second dest |
3357 static const Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormats] = |
3357 static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormats] = |
3358 { |
3358 { |
3359 { |
3359 { |
3360 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
3360 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
3361 }, |
3361 }, |
3362 { |
3362 { |
3757 |
3757 |
3758 #ifdef QT_HAVE_SSE2 |
3758 #ifdef QT_HAVE_SSE2 |
3759 if (features & SSE2) { |
3759 if (features & SSE2) { |
3760 extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags); |
3760 extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags); |
3761 inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2; |
3761 inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2; |
|
3762 } |
|
3763 #endif |
|
3764 #ifdef QT_HAVE_SSSE3 |
|
3765 if (features & SSSE3) { |
|
3766 extern void convert_RGB888_to_RGB32_ssse3(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); |
|
3767 converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_ssse3; |
|
3768 converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_ssse3; |
|
3769 converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_ssse3; |
|
3770 } |
|
3771 #endif |
|
3772 #ifdef QT_HAVE_NEON |
|
3773 if (features & NEON) { |
|
3774 extern void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); |
|
3775 converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_neon; |
|
3776 converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_neon; |
|
3777 converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_neon; |
3762 } |
3778 } |
3763 #endif |
3779 #endif |
3764 } |
3780 } |
3765 |
3781 |
3766 /*! |
3782 /*! |
4819 case Format_ARGB32_Premultiplied: |
4835 case Format_ARGB32_Premultiplied: |
4820 res = QImage(d->width, d->height, d->format); |
4836 res = QImage(d->width, d->height, d->format); |
4821 QIMAGE_SANITYCHECK_MEMORY(res); |
4837 QIMAGE_SANITYCHECK_MEMORY(res); |
4822 for (int i = 0; i < d->height; i++) { |
4838 for (int i = 0; i < d->height; i++) { |
4823 uint *q = (uint*)res.scanLine(i); |
4839 uint *q = (uint*)res.scanLine(i); |
4824 uint *p = (uint*)scanLine(i); |
4840 uint *p = (uint*)constScanLine(i); |
4825 uint *end = p + d->width; |
4841 uint *end = p + d->width; |
4826 while (p < end) { |
4842 while (p < end) { |
4827 *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00); |
4843 *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00); |
4828 p++; |
4844 p++; |
4829 q++; |
4845 q++; |
4833 case Format_RGB16: |
4849 case Format_RGB16: |
4834 res = QImage(d->width, d->height, d->format); |
4850 res = QImage(d->width, d->height, d->format); |
4835 QIMAGE_SANITYCHECK_MEMORY(res); |
4851 QIMAGE_SANITYCHECK_MEMORY(res); |
4836 for (int i = 0; i < d->height; i++) { |
4852 for (int i = 0; i < d->height; i++) { |
4837 ushort *q = (ushort*)res.scanLine(i); |
4853 ushort *q = (ushort*)res.scanLine(i); |
4838 const ushort *p = (const ushort*)scanLine(i); |
4854 const ushort *p = (const ushort*)constScanLine(i); |
4839 const ushort *end = p + d->width; |
4855 const ushort *end = p + d->width; |
4840 while (p < end) { |
4856 while (p < end) { |
4841 *q = ((*p << 11) & 0xf800) | ((*p >> 11) & 0x1f) | (*p & 0x07e0); |
4857 *q = ((*p << 11) & 0xf800) | ((*p >> 11) & 0x1f) | (*p & 0x07e0); |
4842 p++; |
4858 p++; |
4843 q++; |
4859 q++; |
4846 break; |
4862 break; |
4847 case Format_ARGB8565_Premultiplied: |
4863 case Format_ARGB8565_Premultiplied: |
4848 res = QImage(d->width, d->height, d->format); |
4864 res = QImage(d->width, d->height, d->format); |
4849 QIMAGE_SANITYCHECK_MEMORY(res); |
4865 QIMAGE_SANITYCHECK_MEMORY(res); |
4850 for (int i = 0; i < d->height; i++) { |
4866 for (int i = 0; i < d->height; i++) { |
4851 quint8 *p = (quint8*)scanLine(i); |
4867 const quint8 *p = constScanLine(i); |
|
4868 quint8 *q = res.scanLine(i); |
4852 const quint8 *end = p + d->width * sizeof(qargb8565); |
4869 const quint8 *end = p + d->width * sizeof(qargb8565); |
4853 while (p < end) { |
4870 while (p < end) { |
4854 quint16 *q = reinterpret_cast<quint16*>(p + 1); |
4871 q[0] = p[0]; |
4855 *q = ((*q << 11) & 0xf800) | ((*q >> 11) & 0x1f) | (*q & 0x07e0); |
4872 q[1] = (p[1] & 0xe0) | (p[2] >> 3); |
|
4873 q[2] = (p[2] & 0x07) | (p[1] << 3); |
4856 p += sizeof(qargb8565); |
4874 p += sizeof(qargb8565); |
|
4875 q += sizeof(qargb8565); |
4857 } |
4876 } |
4858 } |
4877 } |
4859 break; |
4878 break; |
4860 case Format_RGB666: |
4879 case Format_RGB666: |
4861 res = QImage(d->width, d->height, d->format); |
4880 res = QImage(d->width, d->height, d->format); |
4862 QIMAGE_SANITYCHECK_MEMORY(res); |
4881 QIMAGE_SANITYCHECK_MEMORY(res); |
4863 for (int i = 0; i < d->height; i++) { |
4882 for (int i = 0; i < d->height; i++) { |
4864 qrgb666 *q = reinterpret_cast<qrgb666*>(res.scanLine(i)); |
4883 qrgb666 *q = reinterpret_cast<qrgb666*>(res.scanLine(i)); |
4865 const qrgb666 *p = reinterpret_cast<const qrgb666*>(scanLine(i)); |
4884 const qrgb666 *p = reinterpret_cast<const qrgb666*>(constScanLine(i)); |
4866 const qrgb666 *end = p + d->width; |
4885 const qrgb666 *end = p + d->width; |
4867 while (p < end) { |
4886 while (p < end) { |
4868 const QRgb rgb = quint32(*p++); |
4887 const QRgb rgb = quint32(*p++); |
4869 *q++ = qRgb(qBlue(rgb), qGreen(rgb), qRed(rgb)); |
4888 *q++ = qRgb(qBlue(rgb), qGreen(rgb), qRed(rgb)); |
4870 } |
4889 } |
4872 break; |
4891 break; |
4873 case Format_ARGB6666_Premultiplied: |
4892 case Format_ARGB6666_Premultiplied: |
4874 res = QImage(d->width, d->height, d->format); |
4893 res = QImage(d->width, d->height, d->format); |
4875 QIMAGE_SANITYCHECK_MEMORY(res); |
4894 QIMAGE_SANITYCHECK_MEMORY(res); |
4876 for (int i = 0; i < d->height; i++) { |
4895 for (int i = 0; i < d->height; i++) { |
4877 qargb6666 *q = reinterpret_cast<qargb6666*>(res.scanLine(i)); |
4896 const quint8 *p = constScanLine(i); |
4878 const qargb6666 *p = reinterpret_cast<const qargb6666*>(scanLine(i)); |
4897 const quint8 *end = p + d->width * sizeof(qargb6666); |
4879 const qargb6666 *end = p + d->width; |
4898 quint8 *q = res.scanLine(i); |
4880 while (p < end) { |
4899 while (p < end) { |
4881 const QRgb rgb = quint32(*p++); |
4900 q[0] = (p[1] >> 4) | ((p[2] & 0x3) << 4) | (p[0] & 0xc0); |
4882 *q++ = qRgba(qBlue(rgb), qGreen(rgb), qRed(rgb), qAlpha(rgb)); |
4901 q[1] = (p[1] & 0xf) | (p[0] << 4); |
|
4902 q[2] = (p[2] & 0xfc) | ((p[0] >> 4) & 0x3); |
|
4903 p += sizeof(qargb6666); |
|
4904 q += sizeof(qargb6666); |
4883 } |
4905 } |
4884 } |
4906 } |
4885 break; |
4907 break; |
4886 case Format_RGB555: |
4908 case Format_RGB555: |
4887 res = QImage(d->width, d->height, d->format); |
4909 res = QImage(d->width, d->height, d->format); |
4888 QIMAGE_SANITYCHECK_MEMORY(res); |
4910 QIMAGE_SANITYCHECK_MEMORY(res); |
4889 for (int i = 0; i < d->height; i++) { |
4911 for (int i = 0; i < d->height; i++) { |
4890 ushort *q = (ushort*)res.scanLine(i); |
4912 quint16 *q = (quint16*)res.scanLine(i); |
4891 const ushort *p = (const ushort*)scanLine(i); |
4913 const quint16 *p = (const quint16*)constScanLine(i); |
4892 const ushort *end = p + d->width; |
4914 const quint16 *end = p + d->width; |
4893 while (p < end) { |
4915 while (p < end) { |
4894 *q = ((*p << 10) & 0x7800) | ((*p >> 10) & 0x1f) | (*p & 0x83e0); |
4916 *q = ((*p << 10) & 0x7c00) | ((*p >> 10) & 0x1f) | (*p & 0x3e0); |
4895 p++; |
4917 p++; |
4896 q++; |
4918 q++; |
4897 } |
4919 } |
4898 } |
4920 } |
4899 break; |
4921 break; |
4900 case Format_ARGB8555_Premultiplied: |
4922 case Format_ARGB8555_Premultiplied: |
4901 res = QImage(d->width, d->height, d->format); |
4923 res = QImage(d->width, d->height, d->format); |
4902 QIMAGE_SANITYCHECK_MEMORY(res); |
4924 QIMAGE_SANITYCHECK_MEMORY(res); |
4903 for (int i = 0; i < d->height; i++) { |
4925 for (int i = 0; i < d->height; i++) { |
4904 quint8 *p = (quint8*)scanLine(i); |
4926 const quint8 *p = constScanLine(i); |
|
4927 quint8 *q = res.scanLine(i); |
4905 const quint8 *end = p + d->width * sizeof(qargb8555); |
4928 const quint8 *end = p + d->width * sizeof(qargb8555); |
4906 while (p < end) { |
4929 while (p < end) { |
4907 quint16 *q = reinterpret_cast<quint16*>(p + 1); |
4930 q[0] = p[0]; |
4908 *q = ((*q << 10) & 0x7800) | ((*q >> 10) & 0x1f) | (*q & 0x83e0); |
4931 q[1] = (p[1] & 0xe0) | (p[2] >> 2); |
|
4932 q[2] = (p[2] & 0x03) | ((p[1] << 2) & 0x7f); |
4909 p += sizeof(qargb8555); |
4933 p += sizeof(qargb8555); |
|
4934 q += sizeof(qargb8555); |
4910 } |
4935 } |
4911 } |
4936 } |
4912 break; |
4937 break; |
4913 case Format_RGB888: |
4938 case Format_RGB888: |
4914 res = QImage(d->width, d->height, d->format); |
4939 res = QImage(d->width, d->height, d->format); |
4915 QIMAGE_SANITYCHECK_MEMORY(res); |
4940 QIMAGE_SANITYCHECK_MEMORY(res); |
4916 for (int i = 0; i < d->height; i++) { |
4941 for (int i = 0; i < d->height; i++) { |
4917 quint8 *q = reinterpret_cast<quint8*>(res.scanLine(i)); |
4942 quint8 *q = res.scanLine(i); |
4918 const quint8 *p = reinterpret_cast<const quint8*>(scanLine(i)); |
4943 const quint8 *p = constScanLine(i); |
4919 const quint8 *end = p + d->width * sizeof(qrgb888); |
4944 const quint8 *end = p + d->width * sizeof(qrgb888); |
4920 while (p < end) { |
4945 while (p < end) { |
4921 q[0] = p[2]; |
4946 q[0] = p[2]; |
4922 q[1] = p[1]; |
4947 q[1] = p[1]; |
4923 q[2] = p[0]; |
4948 q[2] = p[0]; |
4925 p += sizeof(qrgb888); |
4950 p += sizeof(qrgb888); |
4926 } |
4951 } |
4927 } |
4952 } |
4928 break; |
4953 break; |
4929 case Format_RGB444: |
4954 case Format_RGB444: |
4930 res = QImage(d->width, d->height, d->format); |
|
4931 QIMAGE_SANITYCHECK_MEMORY(res); |
|
4932 for (int i = 0; i < d->height; i++) { |
|
4933 quint8 *q = reinterpret_cast<quint8*>(res.scanLine(i)); |
|
4934 const quint8 *p = reinterpret_cast<const quint8*>(scanLine(i)); |
|
4935 const quint8 *end = p + d->width * sizeof(qrgb444); |
|
4936 while (p < end) { |
|
4937 q[0] = (p[0] & 0xf0) | ((p[1] & 0x0f) << 8); |
|
4938 q[1] = ((p[0] & 0x0f) >> 8) | (p[1] & 0xf0); |
|
4939 q += sizeof(qrgb444); |
|
4940 p += sizeof(qrgb444); |
|
4941 } |
|
4942 } |
|
4943 break; |
|
4944 case Format_ARGB4444_Premultiplied: |
4955 case Format_ARGB4444_Premultiplied: |
4945 res = QImage(d->width, d->height, d->format); |
4956 res = QImage(d->width, d->height, d->format); |
4946 QIMAGE_SANITYCHECK_MEMORY(res); |
4957 QIMAGE_SANITYCHECK_MEMORY(res); |
4947 for (int i = 0; i < d->height; i++) { |
4958 for (int i = 0; i < d->height; i++) { |
4948 quint8 *q = reinterpret_cast<quint8*>(res.scanLine(i)); |
4959 quint16 *q = reinterpret_cast<quint16*>(res.scanLine(i)); |
4949 const quint8 *p = reinterpret_cast<const quint8*>(scanLine(i)); |
4960 const quint16 *p = reinterpret_cast<const quint16*>(constScanLine(i)); |
4950 const quint8 *end = p + d->width * sizeof(qargb4444); |
4961 const quint16 *end = p + d->width; |
4951 while (p < end) { |
4962 while (p < end) { |
4952 q[0] = (p[0] & 0xf0) | ((p[1] & 0x0f) << 8); |
4963 *q = (*p & 0xf0f0) | ((*p & 0x0f) << 8) | ((*p & 0xf00) >> 8); |
4953 q[1] = ((p[0] & 0x0f) >> 8) | (p[1] & 0xf0); |
4964 p++; |
4954 q += sizeof(qargb4444); |
4965 q++; |
4955 p += sizeof(qargb4444); |
|
4956 } |
4966 } |
4957 } |
4967 } |
4958 break; |
4968 break; |
4959 } |
4969 } |
4960 return res; |
4970 return res; |