colorfilter

Creating a Custom Subclass of ColorFilter?

跟風遠走 提交于 2020-01-24 03:54:06
问题 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. I'm thinking I could simply

Drawable loses color filter after converting into bitmap

末鹿安然 提交于 2020-01-03 20:06:05
问题 I am trying to add a color filer in a drawable and then convert it in Bitmap. The problem is when convert the drawable into bitmap it loses it's color filter.I used drawable in imageview and its have the color filter but using bitmap in imageview doesn't have any color effect. Why this happen ? Thanks in advance. 回答1: Use a canvas to blit the Drawable back onto a bitmap: Canvas canvas; Drawable drawable = <yourDrawable created from wherever>; Bitmap bmp = <your Bitmap which is the same width

Drawable loses color filter after converting into bitmap

非 Y 不嫁゛ 提交于 2020-01-03 20:04:15
问题 I am trying to add a color filer in a drawable and then convert it in Bitmap. The problem is when convert the drawable into bitmap it loses it's color filter.I used drawable in imageview and its have the color filter but using bitmap in imageview doesn't have any color effect. Why this happen ? Thanks in advance. 回答1: Use a canvas to blit the Drawable back onto a bitmap: Canvas canvas; Drawable drawable = <yourDrawable created from wherever>; Bitmap bmp = <your Bitmap which is the same width

setColorFilter is not working sometimes on android drawable

╄→гoц情女王★ 提交于 2020-01-02 19:10:11
问题 I am trying to apply color filter on drawable depending on selected primary color in preferences by user. This is the piece of code I am using. getResources().getDrawable(R.drawable.ic_batman_1) .setColorFilter(ColorHelper.getPrimaryColor(), PorterDuff.Mode.OVERLAY); Problem is that, sometimes, this piece of code does not change the color filter of drawable. I have placed this code in my activity (main activity) onCreate and onResume method. So as soon as app launches, I want this color

What is the best way to apply color filter on hair style with some specified hair style image pattern?

喜你入骨 提交于 2019-12-28 13:58:06
问题 I am developing an android application for hair style salon.I am having two images. One is hairstyle (hair) and another is hair color pattern. I am able to change the color of hair style based on specific rgb value. My code is as below: int color = Color.rgb(182,132, 84); // getting rgb value Paint paint = new Paint(); paint.setColorFilter(new LightingColorFilter(color, 1)); transform.reset(); transform.postTranslate(-width / 2.0f, -height / 2.0f); transform.postRotate(getDegreesFromRadians

Applying ColorFilter to ImageView with ShapedDrawable

人盡茶涼 提交于 2019-12-27 17:23:59
问题 I have an ImageView with android:src set to a ShapedDrawable , namely a white circle. What I want is to colorize this ImageView in runtime responding to some events. imgView.setColorFilter seems to be solution, but after using this (tried different parameters) the image becomes invisible (I don't see it at the screen). How to solve this? And are there better ways to have color circles? 回答1: Alright, I had a quick play with this and noticed your issue of the circles disappearing. Without you

Apply many color filters to the same drawable

那年仲夏 提交于 2019-12-22 04:49:22
问题 I want to apply several color filters in chain to a drawable. Is that possible? Or maybe to create a filter that is the combination of the filters I want to apply. For example, I would like: Drawable d = ...; d.setColorFilter(0x3F000000, Mode.OVERLAY).setColorFilter(0xFF2D2D2D, Mode.SCREEN) 回答1: This is the approach I ended using: Manipulate the Drawable bitmap on a Canvas and apply as many layers as I need, using Paint , it works not only for color filters, but also for any kind of image

Android apply colorMatrix colorFilter on part of imageView with a mask

倖福魔咒の 提交于 2019-12-20 10:47:16
问题 I want to change the brightness on certain part of an image. I know how to use ColorMatrix to change the brightness(or hue) of an image. But it will be applied to the whole image. I have a mask file (black and white image). I want to apply the brightness change only on the the white part of that mask.How to do this in Android? Below is a mask image and the result I want to get. 回答1: for given bitmap and mask: first create a temporary bitmap: bitmap = BitmapFactory.decodeResource(ctx

StateListDrawable to switch colorfilters

只谈情不闲聊 提交于 2019-12-18 02:46:43
问题 I want to create custom buttons to use in a TabHost. I haven been trying to just use the same image resource (png), but have the colorfilter change depending on the state. So I made this bit to serve as the layout for the custom button: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/tab_icon" android:layout_centerInParent="true"

setColorFilter not working

别等时光非礼了梦想. 提交于 2019-12-17 16:01:07
问题 I'm trying to implement a simple colorfilter on an imageview to turn the black image into a white image. In order to achieve that I do the following: weatherImg.setColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY); weatherImg.setImageResource(R.drawable.b_clouded_rain); I've also tried to change to color in the color filter to red and white but all of them have no effect, what am I doing wrong? 回答1: As much as I hate to answer my own questions I found the problem: I should've used: