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

RGB image created with “createImage()" has alpha channel. #388

Closed
processing-bot opened this issue Feb 1, 2022 · 6 comments
Closed

RGB image created with “createImage()" has alpha channel. #388

processing-bot opened this issue Feb 1, 2022 · 6 comments

Comments

@processing-bot
Copy link
Collaborator

Created by: ertdfgcvb

Description

Images created with createImage(w, h, RGB) have an alpha channel.
The alpha channel is filled with 0 once a single pixel is set.

Expected Behavior

RGB images should be opaque (?).

Current Behavior

A newly created RGB image has all pixels in black but once a single pixel is changed trough the set() method the alpha channel is zeroed out (?) for all other pixels.

Steps to Reproduce

PImage a = createImage(10, 10, RGB);
// Uncomment below for a different result!
//image(a, 5, 5); 
a.set(0, 0, color(255,0,0));
image(a, 20, 5);

Your Environment

  • Processing version: 4.0b3
  • Operating System and OS version: MacOS 10.15.7
@processing-bot
Copy link
Collaborator Author

Created by: benfry

Hm, the alpha should be ignored. When I first tried your example I saw the weird behavior—nothing was drawn, and then using set() showed two mostly black rectangles.

Though given that I can't reproduce it, I wonder if it's just a matter of nothing being drawn at all—i.e. the set() call does enough to flush the graphics buffer, but we're dealing with an unrelated glitch.

For what it's worth, in RGB images, the high 8 bits of the pixels should simply be ignored—they might be 0x00 or might be 0xFF depending on how they've been set (i.e. createImage() will leave them at 0x00, but set() will probably make the pixel 0xFF), but their having different values is a red herring as far as debugging goes.

@processing-bot
Copy link
Collaborator Author

Created by: benfry

I would also try with beta 4…

@processing-bot
Copy link
Collaborator Author

Created by: ertdfgcvb

Tested on beta 4 (macOS) with the same outcome.

PImage a = createImage(10, 10, RGB);

// Uncomment below to set a few red pixels:
// after a single set() call the alpha turns 0x00
// a.set(0, 0, color(255,0,0));
// a.set(1, 0, color(255,0,0));
// a.set(2, 0, color(255,0,0));

image(a, 5, 5);

Before set():
Screenshot 2022-02-03 at 11 45 31
After set():
Screenshot 2022-02-03 at 11 45 43

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Thanks, that's a helpful test case.

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Fixed for beta 6.

This is a nasty one because it's partly a performance tradeoff—we could manually set all the pixels to be opaque, but that's a really expensive operation, and in most use cases, the pixels will already be opaque. But we have a better solution for it now.

@processing-bot
Copy link
Collaborator Author

Created by: github-actions[bot]

This issue has been automatically locked. To avoid confusion with reports that have already been resolved, closed issues are automatically locked 30 days after the last comment. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant