mattdesl / mattdesl/stackblur

[BUG] not support the image with alpha channel

Open
#1 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
17
Forks
3
PR merge metrics
No merged PRs in 30d

Description

this bug is in the original ver. ( http://www.quasimondo.com/StackBlurForCanvas )

If the image has alpha channel , the edge of image wlil be light.

It's try to solve this issue , but do sth. is wrong.

I fix it in my simple blur project: https://github.com/finscn/SimpleBlur

the key code is (in doStack method)

```
var _a = ((a_sum * mul_sum) >> shg_sum);
if (_a === 0) {
_r = _g = _b = 0;
} else {
k = 255 / _a;
var _r = ((r_sum * mul_sum) >> shg_sum) * k;
var _g = ((g_sum * mul_sum) >> shg_sum) * k;
var _b = ((b_sum * mul_sum) >> shg_sum) * k;
}

... ...
var npa = pixels[np + 3];
k = npa / 255;
var npr = pixels[np] * k;
var npg = pixels[np + 1] * k;
var npb = pixels[np + 2] * k;
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the doStack method in the JavaScript port and reproduce the light edge with an image that has an alpha channel. Compare its premultiplied-alpha handling with the referenced SimpleBlur implementation and the original StackBlurForCanvas code. Done means transparent or semi-transparent image edges no longer become light after blurring, with the behavior checked against an alpha-channel input.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.