Skip to content

Commit aaf2dd2

Browse files
authored
Bleed entire image (#94)
Hi again, very sorry I didn't get this in with the last PR, but I quite literally just figured out this was an issue independantly 10ish minutes ago. Long story short I was wrong about only needing to bleed one pixel. This is only applicable when the image is being upscaled, not when it's being down-scaled. If you want more info on how / why I came to this conclusion you can read the last couple responses in this devforum post. https://devforum.roblox.com/t/photobooth-plugin/3401720/80
1 parent db1faf2 commit aaf2dd2

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/asset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl Asset {
132132

133133
if let AssetKind::Decal(_) = &kind {
134134
let mut image: DynamicImage = image::load_from_memory(&data)?;
135-
alpha_bleed(&mut image, 1);
135+
alpha_bleed(&mut image);
136136

137137
let format = ImageFormat::from_extension(ext)
138138
.context("Failed to get image format from extension")?;

src/util/alpha_bleed.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::collections::VecDeque;
77
use bit_vec::BitVec;
88
use image::{DynamicImage, GenericImage, GenericImageView, Rgba};
99

10-
pub(crate) fn alpha_bleed(img: &mut DynamicImage, thickness: usize) {
10+
pub(crate) fn alpha_bleed(img: &mut DynamicImage) {
1111
let (w, h) = img.dimensions();
1212

1313
// Tells whether a given position has been touched by the bleeding algorithm
@@ -68,12 +68,10 @@ pub(crate) fn alpha_bleed(img: &mut DynamicImage, thickness: usize) {
6868
visited.set(x, y);
6969
to_visit.push_back((x, y));
7070
}
71-
72-
img.put_pixel(x, y, Rgba([0, 0, 0, 0]));
7371
}
7472
}
7573

76-
for _ in 0..thickness {
74+
loop {
7775
let queue_length = to_visit.len();
7876
if queue_length == 0 {
7977
break;

0 commit comments

Comments
 (0)