mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
feat: add ability to control zoom/angle on generated card image
This commit is contained in:
@@ -99,11 +99,11 @@ void export_images(const SetP& set, const vector<CardP>& cards,
|
||||
void export_image(const SetP& set, const CardP& card, const String& filename);
|
||||
|
||||
/// Generate a bitmap image of a card
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card);
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card);
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card, const double zoom, const Radians angle_radians);
|
||||
|
||||
/// Export a set to Magic Workstation format
|
||||
void export_mws(Window* parent, const SetP& set);
|
||||
|
||||
/// Export a set to Apprentice
|
||||
void export_apprentice(Window* parent, const SetP& set);
|
||||
|
||||
void export_apprentice(Window* parent, const SetP& set);
|
||||
|
||||
+50
-13
@@ -25,15 +25,35 @@ void export_image(const SetP& set, const CardP& card, const String& filename) {
|
||||
}
|
||||
|
||||
class UnzoomedDataViewer : public DataViewer {
|
||||
public:
|
||||
public:
|
||||
UnzoomedDataViewer();
|
||||
UnzoomedDataViewer(double zoom, double angle);
|
||||
virtual ~UnzoomedDataViewer() {};
|
||||
Rotation getRotation() const override;
|
||||
private:
|
||||
double angle = 0.0;
|
||||
};
|
||||
private:
|
||||
double zoom;
|
||||
double angle;
|
||||
bool declared_values;
|
||||
};
|
||||
|
||||
UnzoomedDataViewer::UnzoomedDataViewer()
|
||||
: zoom(1.0)
|
||||
, angle(0.0)
|
||||
, declared_values(false)
|
||||
{}
|
||||
|
||||
UnzoomedDataViewer::UnzoomedDataViewer(const double zoom, const Radians angle = 0.0)
|
||||
: zoom(zoom)
|
||||
, angle(angle)
|
||||
, declared_values(true)
|
||||
{}
|
||||
|
||||
Rotation UnzoomedDataViewer::getRotation() const {
|
||||
if (!stylesheet) stylesheet = set->stylesheet;
|
||||
if (!stylesheet) stylesheet = set->stylesheet;
|
||||
if (declared_values) {
|
||||
return Rotation(angle, stylesheet->getCardRect(), zoom, 1.0, ROTATION_ATTACH_TOP_LEFT);
|
||||
}
|
||||
|
||||
double export_zoom = settings.stylesheetSettingsFor(set->stylesheetFor(card)).export_zoom();
|
||||
bool use_viewer_rotation = !settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_normal_export();
|
||||
|
||||
@@ -42,26 +62,43 @@ Rotation UnzoomedDataViewer::getRotation() const {
|
||||
} else {
|
||||
return Rotation(angle, stylesheet->getCardRect(), export_zoom, 1.0, ROTATION_ATTACH_TOP_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card) {
|
||||
if (!set) throw Error(_("no set"));
|
||||
// create viewer
|
||||
}
|
||||
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card) {
|
||||
if (!set) throw Error(_("no set"));
|
||||
UnzoomedDataViewer viewer = UnzoomedDataViewer();
|
||||
viewer.setSet(set);
|
||||
viewer.setCard(card);
|
||||
// size of cards
|
||||
RealSize size = viewer.getRotation().getExternalSize();
|
||||
// create bitmap & dc
|
||||
Bitmap bitmap((int) size.width, (int) size.height);
|
||||
Bitmap bitmap((int)size.width, (int)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;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card, const double zoom, const Radians angle = 0.0) {
|
||||
if (!set) throw Error(_("no set"));
|
||||
UnzoomedDataViewer viewer = UnzoomedDataViewer(zoom, angle);
|
||||
viewer.setSet(set);
|
||||
viewer.setCard(card);
|
||||
// size of cards
|
||||
RealSize size = viewer.getRotation().getExternalSize();
|
||||
// create bitmap & dc
|
||||
Bitmap bitmap((int)size.width, (int)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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user