Skip to content

Image:drawImage() doesn't behave like BlendMode.NORMAL by default with indexed image #4531

@dacap

Description

@dacap

It looks like Image:drawImage() behaves like BlendMode.SRC instead of BlendMode.NORMAL in indexed image.

This example works:

local a = Image(2, 2, ColorMode.INDEXED)
local b = Image(2, 2, ColorMode.INDEXED)
a:putPixel(0, 0, 0)   a:putPixel(1, 0, 1)
a:putPixel(0, 1, 2)   a:putPixel(1, 1, 3)
b:drawImage(a)
b:drawImage(a, 1, 0)
assert(b:getPixel(0, 0) == 0)   assert(b:getPixel(1, 0) == 0)
assert(b:getPixel(0, 1) == 2)   assert(b:getPixel(1, 1) == 2)

But it should be:

local a = Image(2, 2, ColorMode.INDEXED)
local b = Image(2, 2, ColorMode.INDEXED)
a:putPixel(0, 0, 0)   a:putPixel(1, 0, 1)
a:putPixel(0, 1, 2)   a:putPixel(1, 1, 3)
b:drawImage(a)
b:drawImage(a, 1, 0)
assert(b:getPixel(0, 0) == 0)   assert(b:getPixel(1, 0) == 1) -- This pixel shouldn't be overwritten
                                                              -- because 0 in src=a is mask color
assert(b:getPixel(0, 1) == 2)   assert(b:getPixel(1, 1) == 2)

Metadata

Metadata

Assignees

Labels

bugscriptingRelated to scripting API

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions