how to convert rgb color to int in java

后端 未结 8 1003
再見小時候
再見小時候 2020-11-28 13:11

Paint.setColor is expecting an integer. But what I have is a Color object. I don\'t see a color.getIntValue() in Java? So how do I do

相关标签:
8条回答
  • 2020-11-28 13:36

    If you are developing for Android, Color's method for this is rgb(int, int, int)

    So you would do something like

    myPaint.setColor(Color.rgb(int, int, int)); 
    

    For retrieving the individual color values you can use the methods for doing so:

    Color.red(int color) 
    Color.blue(int color) 
    Color.green(int color) 
    

    Refer to this document for more info

    0 讨论(0)
  • 2020-11-28 13:37

    Try this one:

    Color color = new Color (10,10,10)
    
    
    myPaint.setColor(color.getRGB());
    
    0 讨论(0)
提交回复
热议问题