创建ColorFilter的自定义子类? [英] Creating a Custom Subclass of ColorFilter?

查看:195
本文介绍了创建ColorFilter的自定义子类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,所以这是一定的相关性在ColorMatrixColorFilter我的previous的问题,但我觉得这是一个显著不同的问题。我不知道是否有一种方法 - 或者说,如何扩展ColorFilter类来创建自己的定制彩色滤光片。对于我需要完成什么,我需要写一个自定义过滤器,将查询每一个像素,它的RGB值转换为HSL或实验室,修改色调,将其转换回RGB,以及像素设置为新的值。

Okay, so this is somewhat related to my previous question on the ColorMatrixColorFilter, but I feel it's a significantly different question. I'm wondering if there's a way - or rather, how to extend the ColorFilter class to create my own custom color filter. For what I'm needing to accomplish, I need to write a custom filter that will query each pixel, convert its RGB value to HSL or LAB, modify the hue, convert it back to RGB, and set that pixel to the new value.

我想我可以简单地写一个类,这样做,走在被拉伸和色调偏移来执行量,但它不得不手动呼吁每一个可绘制,每一个可绘制的每个状态,而ColorFilter似乎很好地处理这个问题。鉴于LightingColorFilter和ColorMatrixColorFilter的存在,好像他也可以子,但到目前为止,我努力寻找任何类型的文件都已经徒劳的。我似乎无法找到源$ C ​​$ C任何的三(照明,嘉洛斯,ColorFilter)的;我想他们是在本土code大概做了什么?

I'm thinking I could simply write a class that does this, taking in a Drawable and an amount of hue shift to perform, but it would have to be called manually for each and every Drawable, and every state of every Drawable, whereas the ColorFilter seems to handle this nicely. Given the existence of the LightingColorFilter and ColorMatrixColorFilter, it seems like it can be subclassed, but so far my efforts to find any sort of documentation have been futile. I can't seem to find the source code for any of the three (Lighting, ColorMatrix, ColorFilter); I'm thinking they're probably done in native code?

我的问题是这样的:我怎样才能正确地继承ColorFilter?如果我不能找到一个很好的答案,如果有人能够找到源(我搜索Android的GIT)和后一个链接到的是,这将是有帮助。

My question is this: How can I properly subclass ColorFilter? If I can't find a good answer for that, if anyone is able to find the source (I've searched Android's git) and post a link to that, that would be helpful as well.

谢谢!

推荐答案

正如你所说,在<一个href=\"http://www.google.com/$c$csearch/p?hl=en#uX1GffpyOZk/graphics/java/android/graphics/ColorMatrixColorFilter.java&d=4\"相对=nofollow>来源$ C ​​$ C 显示ColorFilter使用本地code,所以你不能真正继承它。

As you said, the source code shows ColorFilter use native code so you cannot really subclass it.

有可能是没有其他办法比创建自己的类你想要做什么。

There's probably no other way than creating your own class for what you want to do.

这篇关于创建ColorFilter的自定义子类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆