Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaceColor fix #960

Merged
merged 1 commit into from Jul 1, 2014
Merged

replaceColor fix #960

merged 1 commit into from Jul 1, 2014

Conversation

Phaiax
Copy link
Contributor

@Phaiax Phaiax commented Jun 29, 2014

Hey

I had a problem with BitmapData.replaceColor, it worked sometimes and sometimes not.

I figured out that the problem was the different representation of the pixel data types.

The Uint32Array pixel[] value is compared to the return value of a packPixel() call.
Phaser.Color.packPixel(0,0,0,255) = -16777216
The same bits interpreted as uint32 are 4278190080.
The color comparisation will fail even if the color is the same.

This example does not work for me also:
http://examples.phaser.io/_site/view_full.html?d=display&f=bitmapdata+replace+color.js&t=bitmapdata%20replace%20color

I used this hack from stackoverflow to directly fix the packPixel() function.
http://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32

The function Phaser.Color.toRGBA() still implements the "old" behaviour which can result in negative numbers.

Greetings
-- Phaiax

@Phaiax Phaiax changed the title Return type of Phaser.Color.packPixel changed replaceColor fix Jun 29, 2014
photonstorm added a commit that referenced this pull request Jul 1, 2014
@photonstorm photonstorm merged commit 3cbda52 into phaserjs:dev Jul 1, 2014
@photonstorm
Copy link
Collaborator

Thanks, will check this out.

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.

None yet

2 participants