src/video/windib/SDL_dibvideo.c
changeset 1881 61f86f36afb9
parent 1771 8d3ca155c396
child 1882 339d733e3699
equal deleted inserted replaced
1880:9d940db55a91 1881:61f86f36afb9
   411 	hdc = GetDC(SDL_Window);
   411 	hdc = GetDC(SDL_Window);
   412 	depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
   412 	depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
   413 	ReleaseDC(SDL_Window, hdc);
   413 	ReleaseDC(SDL_Window, hdc);
   414 	return(depth);
   414 	return(depth);
   415 #else
   415 #else
       
   416     int depth;
   416     int dib_size;
   417     int dib_size;
   417     LPBITMAPINFOHEADER dib_hdr;
   418     LPBITMAPINFOHEADER dib_hdr;
   418     HDC hdc;
   419     HDC hdc;
   419     HBITMAP hbm;
   420     HBITMAP hbm;
   420 
   421 
   439     GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
   440     GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
   440     GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
   441     GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
   441     DeleteObject(hbm);
   442     DeleteObject(hbm);
   442     ReleaseDC(NULL, hdc);
   443     ReleaseDC(NULL, hdc);
   443 
   444 
       
   445     depth = 0;
   444     switch( dib_hdr->biBitCount )
   446     switch( dib_hdr->biBitCount )
   445     {
   447     {
   446     case 8:     return 8;
   448     case 8:     depth = 8; break;
   447     case 24:    return 24;
   449     case 24:    depth = 24; break;
   448     case 32:    return 32;
   450     case 32:    depth = 32; break;
   449     case 16:
   451     case 16:
   450         if( dib_hdr->biCompression == BI_BITFIELDS ) {
   452         if( dib_hdr->biCompression == BI_BITFIELDS ) {
   451             /* check the red mask */
   453             /* check the red mask */
   452             switch( ((DWORD*)((char*)dib_hdr + dib_hdr->biSize))[0] ) {
   454             switch( ((DWORD*)((char*)dib_hdr + dib_hdr->biSize))[0] ) {
   453                 case 0xf800: return 16;    /* 565 */
   455                 case 0xf800: depth = 16; break;   /* 565 */
   454                 case 0x7c00: return 15;    /* 555 */
   456                 case 0x7c00: depth = 15; break;   /* 555 */
   455             }
   457             }
   456         }
   458         }
   457     }
   459     }
   458     return 0;    /* poo. */
   460     SDL_free(dib_hdr);
       
   461     return depth;
   459 #endif /* NO_GETDIBITS */
   462 #endif /* NO_GETDIBITS */
   460 }
   463 }
   461 
   464 
   462 
   465 
   463 /* Various screen update functions available */
   466 /* Various screen update functions available */
  1022 #endif /* !NO_GAMMA_SUPPORT */
  1025 #endif /* !NO_GAMMA_SUPPORT */
  1023 }
  1026 }
  1024 
  1027 
  1025 void DIB_VideoQuit(_THIS)
  1028 void DIB_VideoQuit(_THIS)
  1026 {
  1029 {
       
  1030 	int i, j;
       
  1031 
  1027 	/* Destroy the window and everything associated with it */
  1032 	/* Destroy the window and everything associated with it */
  1028 	if ( SDL_Window ) {
  1033 	if ( SDL_Window ) {
  1029 		/* Delete the screen bitmap (also frees screen->pixels) */
  1034 		/* Delete the screen bitmap (also frees screen->pixels) */
  1030 		if ( this->screen ) {
  1035 		if ( this->screen ) {
  1031 #ifndef NO_CHANGEDISPLAYSETTINGS
  1036 #ifndef NO_CHANGEDISPLAYSETTINGS
  1059 		{
  1064 		{
  1060 			FreeLibrary(aygshell);
  1065 			FreeLibrary(aygshell);
  1061 			aygshell = NULL;
  1066 			aygshell = NULL;
  1062 		}
  1067 		}
  1063 #endif
  1068 #endif
  1064 
  1069 	}
       
  1070 
       
  1071 	for ( i=0; i < SDL_arraysize(SDL_modelist); ++i ) {
       
  1072 		if ( !SDL_modelist[i] ) {
       
  1073 			continue;
       
  1074 		}
       
  1075 		for ( j=0; SDL_modelist[i][j]; ++j ) {
       
  1076 			SDL_free(SDL_modelist[i][j]);
       
  1077 		}
       
  1078 		SDL_free(SDL_modelist[i]);
       
  1079 		SDL_modelist[i] = NULL;
       
  1080 		SDL_nummodes[i] = 0;
  1065 	}
  1081 	}
  1066 }
  1082 }
  1067 
  1083 
  1068 /* Exported for the windows message loop only */
  1084 /* Exported for the windows message loop only */
  1069 static void DIB_FocusPalette(_THIS, int foreground)
  1085 static void DIB_FocusPalette(_THIS, int foreground)