767{
769 ULONG bytestoread, bytesread;
771
773
777
779 {
786 }
787
790 if (bytesread !=
sizeof(
DWORD) ||
795 This->bih.bV5Size !=
sizeof(BITMAPV5HEADER)))
return E_FAIL;
796
797 bytestoread =
This->bih.bV5Size-
sizeof(
DWORD);
798 hr = IStream_Read(
stream, &
This->bih.bV5Width, bytestoread, &bytesread);
800 if (bytestoread != bytesread)
return E_FAIL;
801
803 This->palette_offset =
This->bih.bV5Size;
804 else
806
808 {
810 {
813 }
814 else
815 {
816 This->bih.bV5Height /= 2;
817 }
818 }
819
820
821
824 {
825 hr = IStream_Read(
stream, &
This->bih.bV5RedMask, 12, &bytesread);
827 if (bytesread != 12)
return E_FAIL;
828 This->bih.bV5AlphaMask = 0;
829 This->palette_offset += 12;
830 }
831
832
834 {
840 {
841 case 1:
842 This->pixelformat = &GUID_WICPixelFormat1bppIndexed;
843 break;
844 case 2:
845 This->pixelformat = &GUID_WICPixelFormat2bppIndexed;
846 break;
847 case 4:
848 This->pixelformat = &GUID_WICPixelFormat4bppIndexed;
849 break;
850 case 8:
851 This->pixelformat = &GUID_WICPixelFormat8bppIndexed;
852 break;
853 case 24:
854 This->pixelformat = &GUID_WICPixelFormat24bppBGR;
855 break;
856 default:
857 This->pixelformat = &GUID_WICPixelFormatUndefined;
858 WARN(
"unsupported bit depth %i for BITMAPCOREHEADER\n", bch->
bcBitCount);
859 break;
860 }
861 }
862 else
863 {
864 TRACE(
"bitmap header=%i compression=%i depth=%i\n",
This->bih.bV5Size,
This->bih.bV5Compression,
This->bih.bV5BitCount);
865 switch(
This->bih.bV5Compression)
866 {
868 This->bitsperpixel =
This->bih.bV5BitCount;
870 switch(
This->bih.bV5BitCount)
871 {
872 case 1:
873 This->pixelformat = &GUID_WICPixelFormat1bppIndexed;
874 break;
875 case 2:
876 This->pixelformat = &GUID_WICPixelFormat2bppIndexed;
877 break;
878 case 4:
879 This->pixelformat = &GUID_WICPixelFormat4bppIndexed;
880 break;
881 case 8:
882 This->pixelformat = &GUID_WICPixelFormat8bppIndexed;
883 break;
884 case 16:
885 This->pixelformat = &GUID_WICPixelFormat16bppBGR555;
886 break;
887 case 24:
888 This->pixelformat = &GUID_WICPixelFormat24bppBGR;
889 break;
890 case 32:
891 This->pixelformat = &GUID_WICPixelFormat32bppBGR;
892 break;
893 default:
894 This->pixelformat = &GUID_WICPixelFormatUndefined;
895 FIXME(
"unsupported bit depth %i for uncompressed RGB\n",
This->bih.bV5BitCount);
896 }
897 break;
899 This->bitsperpixel = 32;
901 This->pixelformat = &GUID_WICPixelFormat32bppBGR;
902 break;
904 This->bitsperpixel = 32;
906 This->pixelformat = &GUID_WICPixelFormat32bppBGR;
907 break;
909 {
912 {
913
914 This->bitsperpixel = 0;
916 This->pixelformat = &GUID_WICPixelFormatUndefined;
917 FIXME(
"Huffman 1D compression is unsupported\n");
918 break;
919 }
920 This->bitsperpixel =
This->bih.bV5BitCount;
922 {
923 if ((
format->bitcount ==
This->bih.bV5BitCount) &&
925 (
format->greenmask ==
This->bih.bV5GreenMask) &&
926 (
format->bluemask ==
This->bih.bV5BlueMask) &&
927 (
format->alphamask ==
This->bih.bV5AlphaMask))
928 {
929 This->read_data_func =
format->read_data_func;
931 break;
932 }
933 }
935 {
937 This->pixelformat = &GUID_WICPixelFormatUndefined;
938 FIXME(
"unsupported bitfields type depth=%i red=%x green=%x blue=%x alpha=%x\n",
939 This->bih.bV5BitCount,
This->bih.bV5RedMask,
This->bih.bV5GreenMask,
This->bih.bV5BlueMask,
This->bih.bV5AlphaMask);
940 }
941 break;
942 }
943 default:
944 This->bitsperpixel = 0;
946 This->pixelformat = &GUID_WICPixelFormatUndefined;
947 FIXME(
"unsupported bitmap type header=%i compression=%i depth=%i\n",
This->bih.bV5Size,
This->bih.bV5Compression,
This->bih.bV5BitCount);
948 break;
949 }
950 }
951
953 {
954
956 if (
This->bih.bV5ClrUsed)
957 palette_count =
This->bih.bV5ClrUsed;
958 else if (
This->bih.bV5BitCount <= 8)
959 palette_count = 1 <<
This->bih.bV5BitCount;
960 else
961 palette_count = 0;
964 else
967 }
968
970
972}
static HRESULT BmpFrameDecode_ReadRLE8(BmpDecoder *This)
static const struct bitfields_format bitfields_formats[]
static HRESULT BmpFrameDecode_ReadRLE4(BmpDecoder *This)
static unsigned int palette_size(DWORD flags)
int seek(void *fd, ulong off, int mode)
#define WINCODEC_ERR_WRONGSTATE
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
struct tagRGBTRIPLE RGBTRIPLE