436{
438 HBITMAP hdib, oldbm, hdib2, oldbm2;
446 char coreBits[256];
455 HPALETTE hpal, oldpal;
460
462
470
472
473
474
477 ok(hdib ==
NULL &&
bits ==
NULL,
"CreateDIBSection failed for invalid parameter: bmi == 0x0\n");
478
483
484
486 "VirtualQuery failed\n");
490 ok(
info.RegionSize == 0x26000,
"0x%lx != 0x26000\n",
info.RegionSize);
494
496
499
500
506
512 ok(hdib ==
NULL,
"CreateDIBSection should fail when asked to create a compressed DIB section\n");
514
523
524
526 "VirtualQuery failed\n");
530 ok(
info.RegionSize == 0x19000,
"0x%lx != 0x19000\n",
info.RegionSize);
534
537
545 colors[0].rgbRed = 0xff;
546 colors[0].rgbGreen = 0;
547 colors[0].rgbBlue = 0;
548 colors[1].rgbRed = 0;
549 colors[1].rgbGreen = 0;
550 colors[1].rgbBlue = 0xff;
551
553 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
556 "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.
dsBmih.
biClrUsed, 2);
557
558
559
562
564 ok(
ret,
"GetDIBits doesn't work with a BITMAPCOREHEADER\n");
567 "GetDIBits didn't fill in the BITMAPCOREHEADER structure properly\n");
568
570 ok(
ret,
"GetDIBits doesn't work with a BITMAPCOREHEADER\n");
571 ok((ccolors[0].rgbtRed == 0xff) && (ccolors[0].rgbtGreen == 0) &&
572 (ccolors[0].rgbtBlue == 0) && (ccolors[1].rgbtRed == 0) &&
573 (ccolors[1].rgbtGreen == 0) && (ccolors[1].rgbtBlue == 0xff),
574 "The color table has not been translated to the old BITMAPCOREINFO format\n");
575
577 ok(hcoredib !=
NULL,
"CreateDIBSection failed with a BITMAPCOREINFO\n");
578
581 ok(
ret,
"GetDIBits doesn't work with a BITMAPCOREHEADER\n");
582 ok((ccolors[0].rgbtRed == 0xff) && (ccolors[0].rgbtGreen == 0) &&
583 (ccolors[0].rgbtBlue == 0) && (ccolors[1].rgbtRed == 0) &&
584 (ccolors[1].rgbtGreen == 0) && (ccolors[1].rgbtBlue == 0xff),
585 "The color table has not been translated to the old BITMAPCOREINFO format\n");
586
588
591
593 ok(
ret == 2,
"GetDIBColorTable returned %d\n",
ret);
595 "GetDIBColorTable returns table 0: r%02x g%02x b%02x res%02x 1: r%02x g%02x b%02x res%02x\n",
596 rgb[0].rgbRed,
rgb[0].rgbGreen,
rgb[0].rgbBlue,
rgb[0].rgbReserved,
597 rgb[1].rgbRed,
rgb[1].rgbGreen,
rgb[1].rgbBlue,
rgb[1].rgbReserved);
598
599 c0 =
RGB(colors[0].rgbRed, colors[0].rgbGreen, colors[0].rgbBlue);
600 c1 =
RGB(colors[1].rgbRed, colors[1].rgbGreen, colors[1].rgbBlue);
601
613
616
617 colors[0].rgbRed = 0xff;
618 colors[0].rgbGreen = 0xff;
619 colors[0].rgbBlue = 0xff;
620 colors[1].rgbRed = 0;
621 colors[1].rgbGreen = 0;
622 colors[1].rgbBlue = 0;
623
625 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
626
628
630
632 ok(
ret == 2,
"GetDIBColorTable returned %d\n",
ret);
634 "GetDIBColorTable returns table 0: r%02x g%02x b%02x res%02x 1: r%02x g%02x b%02x res%02x\n",
635 rgb[0].rgbRed,
rgb[0].rgbGreen,
rgb[0].rgbBlue,
rgb[0].rgbReserved,
636 rgb[1].rgbRed,
rgb[1].rgbGreen,
rgb[1].rgbBlue,
rgb[1].rgbReserved);
637
641
643 for (
i = 0;
i < 16;
i++) {
644 colors[
i].rgbRed =
i;
645 colors[
i].rgbGreen = 16-
i;
646 colors[
i].rgbBlue = 0;
647 }
649 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
652 "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.
dsBmih.
biClrUsed, 16);
655
657
658 for (
i = 0;
i < 128;
i++) {
659 colors[
i].rgbRed = 255 -
i * 2;
660 colors[
i].rgbGreen =
i * 2;
661 colors[
i].rgbBlue = 0;
662 colors[255 -
i].rgbRed = 0;
663 colors[255 -
i].rgbGreen =
i * 2;
664 colors[255 -
i].rgbBlue = 255 -
i * 2;
665 }
667 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
670 "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.
dsBmih.
biClrUsed, 256);
671
673
674 for (
i = 0;
i < 256;
i++) {
677 RGB(colors[
i].rgbRed, colors[
i].rgbGreen, colors[
i].rgbBlue));
678 }
679
683
685
686
687 memset(plogpal, 0,
sizeof(logpalbuf));
690 palent[0].
peRed = 0xff;
693
698 ok(hpal !=
NULL,
"CreatePalette failed\n");
701 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
704
705
706
707
711
713 ok(
ret == 2,
"GetDIBColorTable returned %d\n",
ret);
714 ok(
rgb[0].rgbRed == 0xff &&
rgb[0].rgbBlue == 0xff &&
rgb[0].rgbGreen == 0 &&
715 rgb[1].rgbRed == 0 &&
rgb[1].rgbBlue == 0 &&
rgb[1].rgbGreen == 0xff,
716 "GetDIBColorTable returns table 0: r%02x g%02x b%02x res%02x 1: r%02x g%02x b%02x res%02x\n",
717 rgb[0].rgbRed,
rgb[0].rgbGreen,
rgb[0].rgbBlue,
rgb[0].rgbReserved,
718 rgb[1].rgbRed,
rgb[1].rgbGreen,
rgb[1].rgbBlue,
rgb[1].rgbReserved);
719
720 c0 =
RGB(palent[0].peRed, palent[0].peGreen, palent[0].peBlue);
721 c1 =
RGB(palent[1].peRed, palent[1].peGreen, palent[1].peBlue);
722
737
738
740 bits[13 * 4] =
bits[13*4 + 1] = 0xff;
741
743
745
747 ok(hdib2 !=
NULL,
"CreateDIBSection failed\n");
750
752
753 ok(bits32[0] == 0xff00,
"lower left pixel is %08x\n", bits32[0]);
754 ok(bits32[17] == 0xff00ff,
"bottom but one, left pixel is %08x\n", bits32[17]);
755
759
764
765
767
768 memset(plogpal, 0,
sizeof(logpalbuf));
771
772 for (
i = 0;
i < 128;
i++) {
776 palent[255 -
i].
peRed = 0;
778 palent[255 -
i].
peBlue = 255 -
i * 2;
779 }
780
782 for (
i = 0;
i < 256;
i++) {
784 }
785
787 ok(hpal !=
NULL,
"CreatePalette failed\n");
790 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
793
795
799
801 ok(
ret == 256,
"GetDIBColorTable returned %d\n",
ret);
802 for (
i = 0;
i < 256;
i++) {
803 ok(
rgb[
i].rgbRed == palent[
i].peRed &&
804 rgb[
i].rgbBlue == palent[
i].peBlue &&
805 rgb[
i].rgbGreen == palent[
i].peGreen,
806 "GetDIBColorTable returns table %d: r%02x g%02x b%02x res%02x\n",
808 }
809
810 for (
i = 0;
i < 256;
i++) {
814 RGB(palent[
i].peRed, palent[
i].peGreen, palent[
i].peBlue));
815 }
816
821
824 ok(hpal !=
NULL,
"CreatePalette failed\n");
828 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
831
833
836
839 ok(
ret == 256,
"GetDIBColorTable returned %d\n",
ret);
840 for (
i = 0;
i < 256;
i++)
841 {
842 if (i < pbmi->bmiHeader.biClrUsed)
843 {
844 ok(
rgb[
i].rgbRed == palent[
i % 37].peRed &&
845 rgb[
i].rgbBlue == palent[
i % 37].peBlue &&
846 rgb[
i].rgbGreen == palent[
i % 37].peGreen,
847 "GetDIBColorTable returns table %d: r %02x g %02x b %02x res%02x\n",
850 RGB(palent[
i % 37].peRed, palent[
i % 37].peGreen, palent[
i % 37].peBlue));
851 }
852 else
853 {
854 ok(
rgb[
i].rgbRed == 0 &&
rgb[
i].rgbBlue == 0 &&
rgb[
i].rgbGreen == 0,
855 "GetDIBColorTable returns table %d: r %02x g %02x b %02x res%02x\n",
858 }
859 }
864 for (
i = 0;
i < 256;
i++)
865 {
867 ok(colors[
i].rgbRed == palent[
i % 37].peRed &&
868 colors[
i].rgbBlue == palent[
i % 37].peBlue &&
869 colors[
i].rgbGreen == palent[
i % 37].peGreen,
870 "GetDIBits returns table %d: r %02x g %02x b %02x res%02x\n",
871 i, colors[
i].rgbRed, colors[
i].rgbGreen, colors[
i].rgbBlue, colors[
i].rgbReserved);
872 else
873 ok(colors[
i].rgbRed == 0 && colors[
i].rgbBlue == 0 && colors[
i].rgbGreen == 0,
874 "GetDIBits returns table %d: r %02x g %02x b %02x res%02x\n",
875 i, colors[
i].rgbRed, colors[
i].rgbGreen, colors[
i].rgbBlue, colors[
i].rgbReserved);
876 }
877
881 rgb[0].rgbReserved = 123;
883 ok(
ret == 1,
"SetDIBColorTable returned unexpected result %u\n",
ret );
884 ok(
rgb[0].rgbReserved == 123,
"Expected rgbReserved = 123, got %u\n",
rgb[0].rgbReserved );
885
886 rgb[0].rgbRed =
rgb[0].rgbGreen =
rgb[0].rgbBlue =
rgb[0].rgbReserved = -1;
888 ok(
ret == 1,
"GetDIBColorTable returned unexpected result %u\n",
ret );
889 ok(
rgb[0].rgbRed == 1,
"Expected rgbRed = 1, got %u\n",
rgb[0].rgbRed );
890 ok(
rgb[0].rgbGreen == 2,
"Expected rgbGreen = 2, got %u\n",
rgb[0].rgbGreen );
891 ok(
rgb[0].rgbBlue == 3,
"Expected rgbBlue = 3, got %u\n",
rgb[0].rgbBlue );
892 ok(
rgb[0].rgbReserved == 0,
"Expected rgbReserved = 0, got %u\n",
rgb[0].rgbReserved );
893
897
898
902 ok(hdib !=
NULL,
"CreateDIBSection failed\n");
907 ok(
ret == 0,
"GetDIBColorTable returned %d\n",
ret);
910
914}
static void test_dib_bits_access(HBITMAP hdib, void *bits)
#define test_color(hdc, color, exp)
static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER *bmih)
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
_In_ ULONG _In_ ULONG rgb
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
struct tagLOGPALETTE LOGPALETTE
#define PALETTERGB(r, g, b)
UINT WINAPI SetDIBColorTable(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) const RGBQUAD *prgbq)