0

I type an A in to my custom view on top of it's canvas background which is currently a bitmap and want to, programmatically, get the info of the pixels of the Destination canvas underneath where the A will be. Then do some custom editing to the pixel colors of destination and source in relation to each other just like the BlendModes seem to do, and have the A drawn with the colors postfilter.

I found BlendModes but they are all prebuilt and no idea how to make a custom one.

i looked around and could not find an answer to this

edit: I am making my text beautiful and relational to the background so every character is colored to be harmonic with both background and underlying patterns of change. I would LIKE to be manipulating individual pixel data ~both getting every pixel below the letter ~and setting ~thru custom code ~every pixel ~yet in a nonhorribly laggy way ~like how the BlendModes seem to do.

the nearest way I found was to draw each letter to a blank canvas, have an alpha background, then detect which pixels aren't alpha0, etc etc. But didn't work and I KNOW it would be cost intensive anyway. What I really seek is what the blendmodes are built on. Not the blendmodes themselves ~but how they, without lagging, filter pixel data. Where they get it and where they send it ~so I can place my own custom thing where they are and be getting this pixel info, filtering it, and having my letter paint affected by it ~without lagging. exampleimg

  • The blend modes are all the standard ones that graphics packages use (multiply, overlay etc) and they're just different ways of combining the source and destination pixels to produce a final blended value. So just like with a painting app, you might want to supply different source data, and use masking techniques to create a final composite effect. It really depends what you're trying to do. I'm no expert on it but if you can provide an example of the kind of result you want, someone might be able to point you in the right direction – cactustictacs Apr 11 '23 at 18:37
  • (Also if you really want to access the pixel data, you can do that through the `Bitmap` the `Canvas` is wrapping - but you probably don't want to, the whole point of a `Canvas` is to abstract drawing operations and blending calculations etc so you don't need to poke the pixels yourself) – cactustictacs Apr 11 '23 at 18:38
  • @cactustictacs i clarified more as you suggested thank you. and i DO want to access individual pixel data, but in a nonlagging 'filtering' way like the blendmodes do. i may be looking for something simple and not know it. – Allo Moondragon Apr 13 '23 at 15:45
  • The blend modes come into play when the Canvas is drawing the source data onto the destination data (i.e. what's already in the bitmap), they're basically formulas for calculating how the source and destination values interact to form a final value. So they work as part of a single drawing operation - and at a guess, the graphics package uses native code to make these calculations as fast as possible. Doing your own calculations on the bitmap data (through its byte array) can still be fast - but your example looks complicated. How did you produce that image? What calculations are involved? – cactustictacs Apr 13 '23 at 18:08
  • You can explore the source code here [https://cs.android.com/android/platform/superproject/+/refs/heads/master:frameworks/base/graphics/java/android/graphics/BlendMode.java] but there are a lot of hardcoded constants, I'm not sure how the `Xfermode` class is meant to be subclassed, and the Canvas drawing operations (and Paints) *do* go through native code so we can't look at them easily. I'm not sure we're meant to be able to add our own blend modes through that system unfortunately! (Again, not an expert). You could try manipulating the bitmap data, and worry about performance when it works – cactustictacs Apr 13 '23 at 18:43

0 Answers0