mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Fixed transparancy in image slicer and sharp resample function
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@623 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -360,6 +360,8 @@ void ImageSlicePreview::draw(DC& dc) {
|
||||
Image image = slice.getSlice();
|
||||
if (mask && mask->size == slice.target_size) {
|
||||
mask->setAlpha(image);
|
||||
}
|
||||
if (image.HasAlpha()) {
|
||||
// create bitmap
|
||||
bitmap = Bitmap(image.GetWidth(), image.GetHeight());
|
||||
wxMemoryDC mdc; mdc.SelectObject(bitmap);
|
||||
@@ -446,9 +448,22 @@ void ImageSliceSelector::draw(DC& dc) {
|
||||
int width = int(slice.selection.width * scaleX);
|
||||
int height = int(slice.selection.height * scaleY);
|
||||
// background
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(Color(128,128,128));
|
||||
dc.DrawRectangle(0, 0, s.GetWidth(), s.GetHeight());
|
||||
{
|
||||
RotatedDC rdc(dc, 0, RealRect(0,0,s.x,s.y), 1, QUALITY_LOW);
|
||||
draw_checker(rdc, RealRect(0,0,s.x,s.y));
|
||||
}
|
||||
// edge
|
||||
{
|
||||
wxRegion r(0,0,s.x,s.y);
|
||||
r.Subtract(wxRect(border,border, s.x-2*border, s.y-2*border));
|
||||
dc.SetClippingRegion(r);
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(Color(191,191,191));
|
||||
dc.SetLogicalFunction(wxAND);
|
||||
dc.DrawRectangle(0, 0, s.x, s.y);
|
||||
dc.SetLogicalFunction(wxCOPY);
|
||||
dc.DestroyClippingRegion();
|
||||
}
|
||||
// bitmap : unselected
|
||||
dc.DrawBitmap(bitmap_no_sel, border, border);
|
||||
// draw selected part ungreyed over it
|
||||
@@ -536,6 +551,11 @@ void ImageSliceSelector::createBitmap() {
|
||||
blur_image(img_no_sel, img_no_sel);
|
||||
blur_image(img_no_sel, img_no_sel);
|
||||
desaturate_image(img_no_sel);
|
||||
if (img.HasAlpha()) {
|
||||
// copy alpha
|
||||
img_no_sel.InitAlpha();
|
||||
memcpy(img_no_sel.GetAlpha(), img.GetAlpha(), img.GetWidth() * img.GetHeight());
|
||||
}
|
||||
bitmap_no_sel = Bitmap(img_no_sel);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ void ImageValueEditor::sliceImage(const Image& image) {
|
||||
if (s.ShowModal() == wxID_OK) {
|
||||
// store the image into the set
|
||||
FileName new_image_file = getSet().newFileName(field().name,_("")); // a new unique name in the package
|
||||
s.getImage().SaveFile(getSet().nameOut(new_image_file), wxBITMAP_TYPE_JPEG);
|
||||
Image img = s.getImage();
|
||||
img.SaveFile(getSet().nameOut(new_image_file), img.HasAlpha() ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_JPEG);
|
||||
getSet().actions.add(value_action(valueP(), new_image_file));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user