Skip to content

Image: added copyMergeAlpha(). - #90

Closed
radekdostal wants to merge 1 commit into
nette:masterfrom
radekdostal:copy-merge-alpha
Closed

radekdostal wants to merge 1 commit into
nette:masterfrom
radekdostal:copy-merge-alpha

Conversation

@radekdostal

Copy link
Copy Markdown

Merge two true colour images with variable opacity while maintaining alpha transparency of both images.

@JanTvrdik

Copy link
Copy Markdown
Contributor

馃憥 Too much code for too narrow use-case.

@radekdostal

Copy link
Copy Markdown
Author

I think it isn't narrow use-case. Merging images by method place() produces black background where two pixels with transparency from each image are covered. This new method copyMergeAlpha() produces correctly image (green map on the top with 50% transparency).

example

@enumag

enumag commented Nov 10, 2015

Copy link
Copy Markdown
Contributor

In that case maybe this method should replace the original place method.

@radekdostal

Copy link
Copy Markdown
Author

The dark side of this method is its slowness, because iterating through all pixels. I think, that it has specific use only for images with transparency, so replace the place() method is not a good idea.

@enumag

enumag commented Nov 10, 2015

Copy link
Copy Markdown
Contributor

In that case can you try finding out if the place method can be fixed (without pixel iteration)? I mean there should be same cases of this on the internet.

@radekdostal

Copy link
Copy Markdown
Author

I was unable to find a solution without pixel iteration. Moreover, the method signature is not compatible with place() method, because it allows to use even a fragment of the picture.

@radekdostal

Copy link
Copy Markdown
Author

It is a PHP bug. There is an opened pull request with the same algorithm as I took. So I think that only solution is algorithm with pixel iteration.

@dg

dg commented Nov 10, 2015

Copy link
Copy Markdown
Member

This implementation is extreme slow, method has unclear name and a lot of parameters, gives a very different results for opacity = 0 and opacity = 1 and has swapped what is source and what is destination image.

@dg
dg force-pushed the master branch 2 times, most recently from 46f5434 to ecbbdfc Compare December 3, 2015 12:21
@dg dg closed this Apr 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants