开发者

Can an Android application take on the responsibilities of dynamically coloring image resources via code?

I’m trying to understand how an application can take on some of the coloring responsibilities of an image through code to achieve a more flexible array of coloring options. Let me explain.

Say you design a great looking image in photoshop, maybe an automobile. You make the automobile red. Then, using additional translucent layers, you add the brighter and darker spots to achieve stuff like shadowing or a sparkle in the sunlight. Maybe then you add another layer that is the chrome trim.

I want to then be able to modify that “red automobile” layer without affecting the rest of the shadowing effects that really polish the image. I want to, through code, change the automobile to say blue and have it sparkle and shine just like the red automobile.

First of all, is this possible? If so what do I need to start reading about in order to be able to dynamically adjust the color of an image like this. What classes are available to use that can help me? Are there any pitfalls I need to watch out for?

Secondly, and perhaps most importantly, what do I specifically need to tell my graphic designer I need in order to set me up properly. If I can开发者_如何学JAVA’t communicate what I need properly, it is unlikely I’ll ever be able to write the code to make it look great!

As always, thanks for reading and any help you can provide!


So, you can't take a an image that has been flattened and restore it to the layers that originally composed it. Once an image has been flattened it is essentially a flat 2D grid of pixels.

There are two ways that this could be done.

You can overlay partially transparent images over each other. I don't know your use case, but you can easily display a stack of images with transparent (and partially transparent regions) that occupy the same space the way your layers do in Photoshop. At that point, you can just swap in and out different layers. You can also do this in a View.onDraw(Canvas) method and draw a stack of partially transparent images.

That's one way. Another would be to think in terms of what you can do in Photoshop to a flat image. You can change various aspects of the color of an image the way you'd do with the items in the Image -> Adjust menu in photoshop (brightness and contracts, hue and saturation, color balance, levels, curves, etc). Those things are just equations on pixels, and in some cases rather simple (in other cases, quite complicated though).

If your image is relatively small, you can actually loop through all of its pixels and perform operations on them in well under a second, if that suits your purposes (might be overkill though).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜