fix win32 loading window bypasses RageFile
allow the splash to be a png
This commit is contained in:
@@ -5,25 +5,52 @@
|
|||||||
#include "RageFileManager.h"
|
#include "RageFileManager.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include "SDL_utils.h"
|
||||||
|
|
||||||
HBITMAP g_hBitmap = NULL;
|
static HBITMAP g_hBitmap = NULL;
|
||||||
|
|
||||||
|
/* Load a file into a GDI surface. */
|
||||||
|
HBITMAP LoadWin32Surface( CString fn )
|
||||||
|
{
|
||||||
|
SDL_Surface *s = SDL_LoadImage( fn );
|
||||||
|
if( s == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ConvertSDLSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 );
|
||||||
|
|
||||||
|
HBITMAP bitmap = CreateCompatibleBitmap( GetDC(NULL), s->w, s->h );
|
||||||
|
ASSERT( bitmap );
|
||||||
|
|
||||||
|
HDC BitmapDC = CreateCompatibleDC( GetDC(NULL) );
|
||||||
|
SelectObject( BitmapDC, bitmap );
|
||||||
|
|
||||||
|
/* This is silly, but simple. We only do this once, on a small image. */
|
||||||
|
for( int y = 0; y < s->h; ++y )
|
||||||
|
{
|
||||||
|
unsigned const char *line = ((unsigned char *) s->pixels) + (y * s->pitch);
|
||||||
|
for( int x = 0; x < s->w; ++x )
|
||||||
|
{
|
||||||
|
unsigned const char *data = line + (x*s->format->BytesPerPixel);
|
||||||
|
|
||||||
|
SetPixelV( BitmapDC, x, y, RGB( data[3], data[2], data[1] ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectObject( BitmapDC, NULL );
|
||||||
|
DeleteObject( BitmapDC );
|
||||||
|
|
||||||
|
SDL_FreeSurface( s );
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||||
{
|
{
|
||||||
AppInstance handle;
|
|
||||||
|
|
||||||
switch( msg )
|
switch( msg )
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
/* XXX: Figure out how to use SDL_LoadImage here. */
|
g_hBitmap = LoadWin32Surface( "Data/splash.png" );
|
||||||
g_hBitmap =
|
if( g_hBitmap == NULL )
|
||||||
(HBITMAP)LoadImage(
|
g_hBitmap = LoadWin32Surface( "Data/splash.bmp" );
|
||||||
handle.Get(),
|
|
||||||
DirOfExecutable + "\\..\\Data\\splash.bmp",
|
|
||||||
IMAGE_BITMAP,
|
|
||||||
0, 0,
|
|
||||||
LR_LOADFROMFILE );
|
|
||||||
SendMessage(
|
SendMessage(
|
||||||
GetDlgItem(hWnd,IDC_SPLASH),
|
GetDlgItem(hWnd,IDC_SPLASH),
|
||||||
STM_SETIMAGE,
|
STM_SETIMAGE,
|
||||||
|
|||||||
Reference in New Issue
Block a user