Added 'position hint' to packages, used to specify the order of the packages in a package list;

Added 'pack type', intended for playtesting (random boosters/starters);
Added 'default(_image)' property to ImageStyle, and added the frame fillers for magic;
Added blurring and bold printing (rather hacky) to the text rendering functions (used for "double click to add image" text);
Added 'symmetric overlay' combine mode, which will look really nice for hybrids;
Moved the watermark choices from the game to an include file in magic-watermarks;
Working on a replacement for the image scripting system that plays nicer with the rest of the code. In particular, it will be possible to compare generated images quickly, so they can be updated continuously. This is a work in progress, currently there are two versions of everything.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@327 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-05-09 21:41:15 +00:00
parent 6f7db851a7
commit 3c4729aaa2
63 changed files with 964 additions and 134 deletions
+36 -5
View File
@@ -10,6 +10,8 @@
#include <util/error.hpp>
#include <gui/util.hpp> // clearDC_black
void blur_image(const Image& img_in, Image& img_out);
// ----------------------------------------------------------------------------- : Resampled text
// scaling factor to use when drawing resampled text
@@ -69,13 +71,35 @@ void downsample_to_alpha(Image& img_in, Image& img_out) {
}*/
}
// simple blur
int blur_alpha_pixel(Byte* in, int x, int y, int width, int height) {
return (2 * ( in[0]) + // center
(x == 0 ? in[0] : in[-1]) + // left
(y == 0 ? in[0] : in[-width]) + // up
(x == width - 1 ? in[0] : in[1]) + // right
(y == height - 1 ? in[0] : in[width]) // down
) / 6;
}
// TODO: move me?
void blur_image_alpha(Image& img) {
int width = img.GetWidth(), height = img.GetHeight();
Byte* data = img.GetAlpha();
for (int y = 0 ; y < height ; ++y) {
for (int x = 0 ; x < width ; ++x) {
*data = blur_alpha_pixel(data, x, y, width, height);
++data;
}
}
}
// Draw text by first drawing it using a larger font and then downsampling it
// optionally rotated by an angle
// (w2,h2) = size of text
// (wc,hc) = the corner where drawing should begin, (0,0) for top-left, (1,1) for bottom-right
void draw_resampled_text(DC& dc, const RealRect& rect, int wc, int hc, int angle, const String& text) {
// enlarge slightly
int w = static_cast<int>(rect.width) + 1, h = static_cast<int>(rect.height) + 1;
void draw_resampled_text(DC& dc, const RealRect& rect, int wc, int hc, int angle, const String& text, int blur_radius, int repeat) {
// enlarge slightly; some fonts are larger then the GetTextExtent tells us (especially italic fonts)
int w = static_cast<int>(rect.width) + 3 + 2 * blur_radius, h = static_cast<int>(rect.height) + 1 + 2 * blur_radius;
// determine sub-pixel position
int xi = static_cast<int>(rect.x), yi = static_cast<int>(rect.y);
int xsub = static_cast<int>(text_scaling * (rect.x - xi)), ysub = static_cast<int>(text_scaling * (rect.y - yi));
@@ -87,7 +111,7 @@ void draw_resampled_text(DC& dc, const RealRect& rect, int wc, int hc, int angle
// now draw the text
mdc.SetFont(dc.GetFont());
mdc.SetTextForeground(*wxWHITE);
mdc.DrawRotatedText(text, wc * w * text_scaling + xsub, hc * h * text_scaling + ysub, angle);
mdc.DrawRotatedText(text, (wc * w + blur_radius) * text_scaling + xsub, (hc * h + blur_radius) * text_scaling + ysub, angle);
// get image
mdc.SelectObject(wxNullBitmap);
Image img_large = buffer.ConvertToImage();
@@ -95,7 +119,14 @@ void draw_resampled_text(DC& dc, const RealRect& rect, int wc, int hc, int angle
Image img_small(w, h, false);
fill_image(img_small, dc.GetTextForeground());
downsample_to_alpha(img_large, img_small);
// blur
for (int i = 0 ; i < blur_radius ; ++i) {
blur_image_alpha(img_small);
}
// step 3. draw to dc
dc.DrawBitmap(img_small, xi + static_cast<int>(wc * (rect.width - w)), yi + static_cast<int>(hc * (rect.height - h)));
for (int i = 0 ; i < repeat ; ++i) {
dc.DrawBitmap(img_small, xi + static_cast<int>(wc * (rect.width - w)) - blur_radius,
yi + static_cast<int>(hc * (rect.height - h)) - blur_radius);
}
}