Page MenuHome

Fix T86868: Image Editor "Erase/Add Alpha" brush erase/add all channels
Needs ReviewPublic

Authored by Yuki Hashimoto (hzuika) on Feb 24 2022, 7:05 AM.
This revision needs review, but there are no reviewers specified.

Details

Summary

"Erase/Add Alpha" brush for float image erases/adds only alpha channel, just as it does for byte image.


I tested with the .blend file in T86868.
Non-float image means byte image in source code.

Bug (Note that there is a black area after "Add alpha" in float image.)

Fix ("Add alpha" returns to the original color.)


Reference

The implementation for byte image.

MINLINE void blend_color_erase_alpha_byte(uchar dst[4], const uchar src1[4], const uchar src2[4])
{
  if (src2[3] != 0) {
    /* straight so just modify alpha channel */
    const int t = src2[3];

    dst[0] = src1[0];
    dst[1] = src1[1];
    dst[2] = src1[2];
    dst[3] = (uchar)max_ii(src1[3] - divide_round_i(t * src2[3], 255), 0);
  }
  else {
    /* no op */
    copy_v4_v4_uchar(dst, src1);
  }
}

MINLINE void blend_color_add_alpha_byte(uchar dst[4], const uchar src1[4], const uchar src2[4])
{
  if (src2[3] != 0) {
    /* straight so just modify alpha channel */
    const int t = src2[3];

    dst[0] = src1[0];
    dst[1] = src1[1];
    dst[2] = src1[2];
    dst[3] = (uchar)min_ii(src1[3] + divide_round_i(t * src2[3], 255), 255);
  }
  else {
    /* no op */
    copy_v4_v4_uchar(dst, src1);
  }
}

Diff Detail

Repository
rB Blender
Branch
t86868 (branched from master)
Build Status
Buildable 20713
Build 20713: arc lint + arc unit

Event Timeline

Yuki Hashimoto (hzuika) requested review of this revision.Feb 24 2022, 7:05 AM

No idea why you put me as reviewer out of the blue like that... but I have no time for sculpt/paint module currently.

No idea why you put me as reviewer out of the blue like that... but I have no time for sculpt/paint module currently.

I have assigned you to be a reviewer because you were the module member and the last one to operate this task.
I apologize for the inconvenience.