mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
initial checkin of C++ port (in progress)
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@2 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/util.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <wx/mstream.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : DC related
|
||||
|
||||
/// Fill a DC with a single color
|
||||
void clearDC(DC& dc, const wxBrush& brush) {
|
||||
wxSize size = dc.GetSize();
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(brush);
|
||||
dc.DrawRectangle(0, 0, size.GetWidth(), size.GetHeight());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image related
|
||||
|
||||
Image loadResourceImage(String name) {
|
||||
#ifdef __WXMSW__
|
||||
// Load resource
|
||||
// based on wxLoadUserResource
|
||||
// The image can be in an IMAGE resource, in any file format
|
||||
HRSRC hResource = ::FindResource(wxGetInstance(), name, _("IMAGE"));
|
||||
if ( hResource == 0 ) throw InternalError(_("Resource not found: ") + name);
|
||||
|
||||
HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
|
||||
if ( hData == 0 ) throw InternalError(_("Resource not an image: ") + name);
|
||||
|
||||
char* data = (char *)::LockResource(hData);
|
||||
if ( !data ) throw InternalError(_("Resource cannot be locked: ") + name);
|
||||
|
||||
int len = ::SizeofResource(wxGetInstance(), hResource);
|
||||
wxMemoryInputStream stream(data, len);
|
||||
return wxImage(stream);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user