How to change color of image in JavaFX -


i have png image this:

png image

i want change image this:

enter image description here

how can in javafx?

as don't care if vector shape or bitmap, i'll outline solutions using bitmap here. if wanted vector shape, believe need work vector input result.


use coloradjust effect brightness set minimum (-1). cache result speed.

speed

here sample creates shadow outline of image:

import javafx.application.application; import javafx.scene.*; import javafx.scene.effect.coloradjust; import javafx.scene.image.*; import javafx.stage.stage;  public class shadow extends application {     @override      public void start(stage stage) throws exception {         imageview imageview = new imageview(             new image(                 "http://i.stack.imgur.com/jbt1h.png"             )         );          coloradjust blackout = new coloradjust();         blackout.setbrightness(-1.0);          imageview.seteffect(blackout);         imageview.setcache(true);         imageview.setcachehint(cachehint.speed);          stage.setscene(new scene(new group(imageview)));         stage.show();     }      public static void main(string[] args) {         application.launch();     } } 

here sample adjusts color of image, hover on smurfette make blush.

smurfette blushing smurfette

import javafx.application.application; import javafx.beans.binding.bindings; import javafx.scene.*; import javafx.scene.effect.*; import javafx.scene.image.*; import javafx.scene.paint.color; import javafx.stage.stage;  public class shadow extends application {     @override     public void start(stage stage) throws exception {         image image = new image(                 "http://icons.iconarchive.com/icons/designbolts/smurfs-movie/128/smurfette-icon.png"         );          imageview imageview = new imageview(image);         imageview.setclip(new imageview(image));          coloradjust monochrome = new coloradjust();         monochrome.setsaturation(-1.0);          blend blush = new blend(                 blendmode.multiply,                 monochrome,                 new colorinput(                         0,                         0,                         imageview.getimage().getwidth(),                         imageview.getimage().getheight(),                         color.red                 )         );          imageview.effectproperty().bind(                 bindings                     .when(imageview.hoverproperty())                         .then((effect) blush)                         .otherwise((effect) null)         );          imageview.setcache(true);         imageview.setcachehint(cachehint.speed);          stage.setscene(new scene(new group(imageview), color.aqua));         stage.show();     }      public static void main(string[] args) {         application.launch();     } } 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -