moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

Add a ColorFIlter to the ImageView #51

Closed mcff2 closed 10 years ago

mcff2 commented 10 years ago

Hi,

for some application, I need to adjust the tile brightness. So I added a ColorFIlter to the imageview when it is created.

However the result is that :+1:

Where should I add my ColorFilter in the code ?

Thanks !

Eteokles commented 10 years ago

Maybe you can create an extended class of ImageView with the ColorFilter...

moagrius commented 10 years ago

I've never worked with ColorFilter before, but I believe you can apply it to any drawable.

You might be able to do something wtih a custom implementation of BitmapDecoder, but since that returns a bitmap, not a drawable, it might not work. If you can get it to work here (maybe by decoding the bitmap, wrapping it in a drawable, applying the filter, then getting back the modified bitmap), it'd certainly be the easiest way. Take a look at the BitmapDecoder classes and the [setTileDecoder](http://moagrius.github.io/TileView/com/qozix/tileview/TileView.html#setTileDecoder(com.qozix.tileview.graphics.BitmapDecoder) method.

That said, again, I'm not sure it's possible.

The most efficient way would probably be to hack the core... TileManager is the class that controls (and is the superview) of all Tiles, and is probably where you want to be. The TileManager instance member is a private property, so as I said a hack would be required.

HTH

mcff2 commented 10 years ago

Hi, my question is in fact not how to use a ColorFilter. As mogrius said, any drawable supports ColorFilter. My question is where to put it.

I put it inside the Tile.render() method, which produces what I wrote above : it works for one second, then the tile gets back its original colors.

moagrius commented 10 years ago

I'd probably try to override TileManager.onDraw and apply the filter there, once (on just the parent, not each tile), but as I said I don't have any experience with ColorFilter so it's just a guess.

moagrius commented 10 years ago

@mcff2 I just had another thought - I can't see any reason why it would work "for a second" then revert, unless it has something to do with the transition. Try tileView.setTransitionsEnabled(false); and see if that helps...

moagrius commented 10 years ago

no response in a few days - i'm going to close the issue for now. @mcff2 post back if you still need help and i'll re-open