Skip to content

Commit

Permalink
Remove transparent padding from the status icon image files.
Browse files Browse the repository at this point in the history
Just removing transparency from all images on the top bar and side bar causes other issues, particularly with the unit sprite and the clock icon alignment.

Fixes wesnoth#8335
  • Loading branch information
Pentarctagon committed Feb 2, 2024
1 parent 37a45c3 commit 5de4e5a
Show file tree
Hide file tree
Showing 14 changed files with 1 addition and 107 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/core/images/misc/stunned-status-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/misc/invisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/misc/invulnerable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/misc/petrified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/misc/poisoned.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/misc/slowed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/misc/unhealable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3066,7 +3066,7 @@ void display::draw_report(const std::string& report_name, bool tooltip_test)
if (used_ellipsis) goto skip_element;

// Draw an image element.
texture img(image::get_texture(t+"~CROP_TRANSPARENCY()"));
texture img(image::get_texture(t));

if (!img) {
ERR_DP << "could not find image for report: '" << t << "'";
Expand Down
11 changes: 0 additions & 11 deletions src/image_modifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,6 @@ surface gs_modification::operator()(const surface& src) const
return greyscale_image(src);
}

surface crop_transparency_modification::operator()(const surface& src) const
{
return get_non_transparent_portion(src);
}

surface bw_modification::operator()(const surface& src) const
{
return monochrome_image(src, threshold_);
Expand Down Expand Up @@ -755,12 +750,6 @@ REGISTER_MOD_PARSER(GS, )
return std::make_unique<gs_modification>();
}

// crop transparent padding
REGISTER_MOD_PARSER(CROP_TRANSPARENCY, )
{
return std::make_unique<crop_transparency_modification>();
}

// Black and white
REGISTER_MOD_PARSER(BW, args)
{
Expand Down
9 changes: 0 additions & 9 deletions src/image_modifications.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@ class gs_modification : public modification
virtual surface operator()(const surface& src) const;
};

/**
* Crop transparent padding (CROP_TRANSPARENCY) modification.
*/
class crop_transparency_modification : public modification
{
public:
virtual surface operator()(const surface& src) const;
};

/**
* Black and white (BW) modification.
*/
Expand Down
84 changes: 0 additions & 84 deletions src/sdl/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include <boost/circular_buffer.hpp>
#include <boost/math/constants/constants.hpp>

static lg::log_domain log_display("display");
#define ERR_DP LOG_STREAM(err, log_display)

version_info sdl::get_version()
{
SDL_version sdl_version;
Expand Down Expand Up @@ -1848,84 +1845,3 @@ struct not_alpha
};

}

surface get_non_transparent_portion(const surface &surf)
{
if(surf == nullptr)
return nullptr;

surface nsurf = surf.clone();
if(nsurf == nullptr) {
PLAIN_LOG << "failed to make neutral surface";
return nullptr;
}

SDL_Rect res {0,0,0,0};
const not_alpha calc;

surface_lock lock(nsurf);
const uint32_t* const pixels = lock.pixels();

int n;
for(n = 0; n != nsurf->h; ++n) {
const uint32_t* const start_row = pixels + n*nsurf->w;
const uint32_t* const end_row = start_row + nsurf->w;

if(std::find_if(start_row,end_row,calc) != end_row)
break;
}

res.y = n;

for(n = 0; n != nsurf->h-res.y; ++n) {
const uint32_t* const start_row = pixels + (nsurf->h-n-1)*surf->w;
const uint32_t* const end_row = start_row + nsurf->w;

if(std::find_if(start_row,end_row,calc) != end_row)
break;
}

// The height is the height of the surface,
// minus the distance from the top and
// the distance from the bottom.
res.h = nsurf->h - res.y - n;

for(n = 0; n != nsurf->w; ++n) {
int y;
for(y = 0; y != nsurf->h; ++y) {
const uint32_t pixel = pixels[y*nsurf->w + n];
if(calc(pixel))
break;
}

if(y != nsurf->h)
break;
}

res.x = n;

for(n = 0; n != nsurf->w-res.x; ++n) {
int y;
for(y = 0; y != nsurf->h; ++y) {
const uint32_t pixel = pixels[y*nsurf->w + surf->w - n - 1];
if(calc(pixel))
break;
}

if(y != nsurf->h)
break;
}

res.w = nsurf->w - res.x - n;

surface cropped = get_surface_portion(nsurf, res);
if(cropped && res.w > 0 && res.h > 0) {
surface scaled = scale_surface(cropped, res.w, res.h);
if(scaled) {
return scaled;
}
}

ERR_DP << "Failed to either crop or scale the surface";
return nsurf;
}
2 changes: 0 additions & 2 deletions src/sdl/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ surface rotate_90_surface(const surface &surf, bool clockwise);
surface flip_surface(const surface &surf);
surface flop_surface(const surface &surf);

surface get_non_transparent_portion(const surface &surf);

/**
* Helper methods for setting/getting a single pixel in an image.
* Lifted from http://sdl.beuc.net/sdl.wiki/Pixel_Access
Expand Down

0 comments on commit 5de4e5a

Please sign in to comment.