Commit 0514e8dd authored by twanvl's avatar twanvl

Added image export, tested mtgeditor import

parent 73d6577a
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <data/format/clipboard.hpp> #include <data/format/clipboard.hpp>
#include <data/format/formats.hpp>
#include <data/card.hpp> #include <data/card.hpp>
#include <data/set.hpp> #include <data/set.hpp>
#include <data/game.hpp> #include <data/game.hpp>
...@@ -77,7 +78,7 @@ CardOnClipboard::CardOnClipboard(const SetP& set, const CardP& card) { ...@@ -77,7 +78,7 @@ CardOnClipboard::CardOnClipboard(const SetP& set, const CardP& card) {
// TODO // TODO
//Add( new TextDataObject(_("card"))) //Add( new TextDataObject(_("card")))
// Conversion to bitmap format // Conversion to bitmap format
// Add(new BitmapDataObject(exportImageBmp(set, card))); Add(new wxBitmapDataObject(export_bitmap(set, card)));
// Conversion to serialized card format // Conversion to serialized card format
Add(new CardDataObject(set, card), true); Add(new CardDataObject(set, card), true);
} }
//+----------------------------------------------------------------------------+
//| 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 <data/format/formats.hpp>
#include <data/set.hpp>
#include <data/settings.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : Single card export
void export_image(const SetP& set, const CardP& card, const String& filename) {
Image img = export_bitmap(set, card).ConvertToImage();
img.SaveFile(filename); // can't use Bitmap::saveFile, it wants to know the file type
// but image.saveFile determines it automagicly
}
Bitmap export_bitmap(const SetP& set, const CardP& card) {
// create viewer
DataViewer viewer;
viewer.setSet(set);
viewer.setCard(card);
// style to use
StyleSheetP style = set->stylesheetFor(card);
// size of cards
if (settings.stylesheetSettingsFor(*style).card_normal_export()) {
// TODO
// viewer.rotation.angle = 0;
// viewer.rotation.zoom = 1.0;
}
RealSize size = viewer.getRotation().getExternalRect().size();
// create bitmap & dc
Bitmap bitmap(size.width, size.height);
if (!bitmap.Ok()) throw InternalError(_("Unable to create bitmap"));
wxMemoryDC dc;
dc.SelectObject(bitmap);
// draw
viewer.draw(dc);
dc.SelectObject(wxNullBitmap);
return bitmap;
}
// ----------------------------------------------------------------------------- : Multiple card export
...@@ -192,7 +192,12 @@ SetP MtgEditorFileFormat::importSet(const String& filename) { ...@@ -192,7 +192,12 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
// Load stylesheet // Load stylesheet
if (layout != _("8e")) { if (layout != _("8e")) {
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("old")); try {
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("old"));
} catch (const Error&) {
// If old style doesn't work try the new one
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("new"));
}
} else { } else {
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("new")); set->stylesheet = StyleSheet::byGameAndName(*set->game, _("new"));
} }
......
...@@ -1503,6 +1503,45 @@ ...@@ -1503,6 +1503,45 @@
<File <File
RelativePath=".\data\format\html.cpp"> RelativePath=".\data\format\html.cpp">
</File> </File>
<File
RelativePath=".\data\format\image.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Profile Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode fast build|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
</File>
<File <File
RelativePath=".\data\format\mse1.cpp"> RelativePath=".\data\format\mse1.cpp">
</File> </File>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment