Mercurial > sdl-ios-xcode
comparison src/video/windib/SDL_dibvideo.c @ 1292:59c7a470a51e
Fixed palette bug on non-WinCE
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 29 Jan 2006 22:23:54 +0000 |
parents | 31331c444ea2 |
children | c3e36ac8a94c |
comparison
equal
deleted
inserted
replaced
1291:31331c444ea2 | 1292:59c7a470a51e |
---|---|
771 } | 771 } |
772 | 772 |
773 | 773 |
774 int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 774 int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) |
775 { | 775 { |
776 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) | |
777 HDC hdc, mdc; | |
776 RGBQUAD *pal; | 778 RGBQUAD *pal; |
779 #else | |
780 HDC hdc; | |
781 #endif | |
777 int i; | 782 int i; |
778 #if (_WIN32_WCE < 400 ) | |
779 HDC hdc; | |
780 #else | |
781 HDC hdc, mdc; | |
782 #endif | |
783 | 783 |
784 /* Update the display palette */ | 784 /* Update the display palette */ |
785 hdc = GetDC(SDL_Window); | 785 hdc = GetDC(SDL_Window); |
786 if ( screen_pal ) { | 786 if ( screen_pal ) { |
787 PALETTEENTRY *entries; | 787 PALETTEENTRY *entries; |
796 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); | 796 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); |
797 SelectPalette(hdc, screen_pal, FALSE); | 797 SelectPalette(hdc, screen_pal, FALSE); |
798 RealizePalette(hdc); | 798 RealizePalette(hdc); |
799 } | 799 } |
800 | 800 |
801 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) | |
801 /* Copy palette colors into DIB palette */ | 802 /* Copy palette colors into DIB palette */ |
802 pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD)); | 803 pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD)); |
803 for ( i=0; i<ncolors; ++i ) { | 804 for ( i=0; i<ncolors; ++i ) { |
804 pal[i].rgbRed = colors[i].r; | 805 pal[i].rgbRed = colors[i].r; |
805 pal[i].rgbGreen = colors[i].g; | 806 pal[i].rgbGreen = colors[i].g; |
806 pal[i].rgbBlue = colors[i].b; | 807 pal[i].rgbBlue = colors[i].b; |
807 pal[i].rgbReserved = 0; | 808 pal[i].rgbReserved = 0; |
808 } | 809 } |
809 | 810 |
810 /* Set the DIB palette and update the display */ | 811 /* Set the DIB palette and update the display */ |
811 #if ( _WIN32_WCE >= 400 ) | |
812 mdc = CreateCompatibleDC(hdc); | 812 mdc = CreateCompatibleDC(hdc); |
813 SelectObject(mdc, screen_bmp); | 813 SelectObject(mdc, screen_bmp); |
814 SetDIBColorTable(mdc, firstcolor, ncolors, pal); | 814 SetDIBColorTable(mdc, firstcolor, ncolors, pal); |
815 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, | 815 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, |
816 mdc, 0, 0, SRCCOPY); | 816 mdc, 0, 0, SRCCOPY); |