Skip to content

Commit

Permalink
Added proper toolbar bitmap scaling. Fixes #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfprimm committed Dec 8, 2016
1 parent 7a5db58 commit 2814c10
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 21 deletions.
16 changes: 11 additions & 5 deletions blitzide/mainframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,24 @@ int MainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ){

if( !toolbmp ){
BITMAP bm;
int scale=(int)GetDPIScaleX();
string t;
if ( scale > 0 ){
t=prefs.homeDir+"/cfg/ide_toolbar@"+string(itoa(scale))+".bmp";
}else{
bool scale_bmp=false;
string t=prefs.homeDir+"/cfg/ide_toolbar@"+string(itoa(GetDPIScaleX()))+".bmp";

if( !PathFileExists(t.c_str()) ){
t=prefs.homeDir+"/cfg/ide_toolbar.bmp";
scale_bmp=true;
}
toolbmp=(HBITMAP)LoadImage( 0,t.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_LOADMAP3DCOLORS );
if( !toolbmp ){
AfxMessageBox( "toolbar bitmap failed to load!" );
ExitProcess(0);
}

if( scale_bmp ){
GetObject( toolbmp,sizeof(bm),&bm );
toolbmp=ScaleBitmap( toolbmp,bm.bmWidth*GetDPIScaleX(),bm.bmHeight*GetDPIScaleY() );
}

GetObject( toolbmp,sizeof(bm),&bm );
int n=0;
for( int k=0;k<toolcnt;++k ) if( toolbuts[k]!=ID_SEPARATOR ) ++n;
Expand Down
20 changes: 12 additions & 8 deletions debugger/mainframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,25 @@ int MainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ){

prefs.open();

string tb;
int scale=(int)GetDPIScaleX();
if (scale > 1) {
tb=prefs.homeDir+"/cfg/dbg_toolbar@"+string(itoa(scale))+".bmp";
} else {
bool scale_bmp=false;
string tb=prefs.homeDir+"/cfg/dbg_toolbar@"+string(itoa(GetDPIScaleX()))+".bmp";;

if( !PathFileExists(tb.c_str()) ){
tb=prefs.homeDir+"/cfg/dbg_toolbar.bmp";
scale_bmp=true;
}

//Toolbar
HBITMAP toolbmp=(HBITMAP)LoadImage(
0,tb.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_LOADMAP3DCOLORS );
HBITMAP toolbmp=(HBITMAP)LoadImage( 0,tb.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_LOADMAP3DCOLORS );

BITMAP bm;
GetObject( toolbmp,sizeof(bm),&bm );

if( scale_bmp ){
GetObject( toolbmp,sizeof(bm),&bm );
toolbmp=ScaleBitmap( toolbmp,bm.bmWidth*GetDPIScaleX(),bm.bmHeight*GetDPIScaleY() );
}

GetObject( toolbmp,sizeof(bm),&bm );
int n=0;
UINT toolbuts[]={ ID_STOP,ID_RUN,ID_STEPOVER,ID_STEPINTO,ID_STEPOUT,ID_END };
int toolcnt=sizeof(toolbuts)/sizeof(UINT);
Expand Down
5 changes: 3 additions & 2 deletions make_release.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@echo off
echo "Building x86..."
premake5 vs2015 && devenv build\blitz3d.sln /rebuild "release|win32" || exit /b
echo "Building x64..."
premake5 vs2015 && devenv build\blitz3d.sln /rebuild "release|win64" || exit /b
rem echo "Building x64..."
rem premake5 vs2015 && devenv build\blitz3d.sln /rebuild "release|win64" || exit /b

echo "Removing intermediate files..."
del /F _release\bin\.vs
del /Q _release\bin\*.ilk _release\bin\*.pcb _release\bin\*.pdb _release\bin\*.lib _release\bin\*.exp
del /Q _release\*.ilk _release\*.pcb _release\*.pdb
del /F _release\cfg\blitzide.prefs
del /F _release\tmp
del /F _release\cfg\blitzide.prefs
6 changes: 0 additions & 6 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ project "bblaunch"
kind "WindowedApp"
language "C++"

-- removeplatforms "win64"

files { "bblaunch/bblaunch.cpp" }

filter "platforms:win32 or win64"
Expand All @@ -162,8 +160,6 @@ project "bblaunch"

characterset "Unicode"

-- linkoptions "/force"

links { "dxguid", "kernel32", "user32", "gdi32", "winspool", "comdlg32", "advapi32", "shell32", "ole32", "oleaut32", "uuid", "odbc32", "odbccp32" }

project "bbruntime_dll"
Expand All @@ -179,8 +175,6 @@ project "bbruntime_dll"
-- suppress libraw warnings
disablewarnings "4217"

-- linkoptions "/force"

files {
"bbruntime_dll/bbruntime_dll.h",
"bbruntime_dll/bbruntime_dll.cpp",
Expand Down
29 changes: 29 additions & 0 deletions stdutil/stdutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,32 @@ qstreambuf::int_type qstreambuf::overflow( qstreambuf::int_type c ){
*pptr()=traits_type::to_char_type( c );
pbump( 1 );return traits_type::not_eof( c );
}

HBITMAP ScaleBitmap( HBITMAP bmp,int width,int height ){
HDC src,dest;
src=CreateCompatibleDC( NULL );
dest=CreateCompatibleDC( NULL );
BITMAP bm;
GetObject( bmp,sizeof(bm),&bm );
HBITMAP result=CreateCompatibleBitmap( GetDC(NULL),width,height );
HBITMAP old_src=(HBITMAP)SelectObject( src,bmp );
HBITMAP old_dest=(HBITMAP)SelectObject( dest,result );
StretchBlt( dest,0,0,width,height,src,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY );
SelectObject( src, old_src );
SelectObject( dest, old_dest );
return result;
}
// HBITMAP ScaleBitmap( HBITMAP bmp,int width,int height ){
// CDC src,dest;
// src.CreateCompatibleDC( NULL );
// dest.CreateCompatibleDC( NULL );
// BITMAP bm;
// ::GetObject( bmp,sizeof(bm),&bm );
// HBITMAP result=::CreateCompatibleBitmap( CClientDC(NULL),width,height );
// HBITMAP old_src=(HBITMAP)::SelectObject( src.m_hDC,bmp );
// HBITMAP old_dest=(HBITMAP)::SelectObject( dest.m_hDC,result );
// dest.StretchBlt( 0,0,width,height,&src,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY );
// ::SelectObject( src.m_hDC, old_src );
// ::SelectObject( dest.m_hDC, old_dest );
// return result;
// }
4 changes: 4 additions & 0 deletions stdutil/stdutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <string>
#include <iostream>

#include <windows.h>

#ifdef MEMDEBUG

void * _cdecl operator new( size_t size );
Expand Down Expand Up @@ -109,4 +111,6 @@ class pool{
void destroy( pointer p ){ p->~T(); }
};

HBITMAP ScaleBitmap( HBITMAP bmp,int width,int height );

#endif

0 comments on commit 2814c10

Please sign in to comment.