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

Rendering on grayscale bitmap fails #7

Closed
GoogleCodeExporter opened this issue Jul 24, 2015 · 2 comments
Closed

Rendering on grayscale bitmap fails #7

GoogleCodeExporter opened this issue Jul 24, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Bitmap bm = Bitmap.createBitmap((int) w, (int) h, Bitmap.config.ALPHA_8);
Canvas bmcanvas = new Canvas(bm);

// Render our document scaled to fit inside our canvas dimensions
svg.renderToCanvas(bmcanvas, null, 96f, AspectRatioAlignment.xMidYMid, 
AspectRatioScale.MEET);


What is the expected output? What do you see instead?
I expected bm to be a grayscale bitmap, instead it is all black.

What version of the product are you using? On what operating system?
Latest

Please provide any additional information below.


Original issue reported on code.google.com by argonned...@gmail.com on 17 Jun 2013 at 7:32

@GoogleCodeExporter
Copy link
Author

Original comment by paul.leb...@gmail.com on 17 Jun 2013 at 10:51

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

ALPHA_8 doesn't create an 8-bit greyscale bitmap. It creates a bitmap that 
represents an alpha channel. From the Bitmap javadoc:

"Each pixel is stored as a single translucency (alpha) channel."

If you need a greyscale bitmap, you would need to render to a 565 or 8888. Then 
convert it yourself, or paint the bitmap using a ColorMatrixColorFilter.

For an exmple of the latter, see: 
http://stackoverflow.com/questions/3373860/convert-a-bitmap-to-grayscale-in-andr
oid 

Marking Invalid, as this is not a bug with the library.

If there is demand, I may add ColorMtrix support to the library in a future 
version.

Original comment by paul.leb...@gmail.com on 17 Jun 2013 at 11:22

  • Changed state: Invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant