Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Java create bitmap from hex value

Can anyone suggest a way to create a small solid colored bitmap image from a hex value?

like image 869
Paul Avatar asked Jul 12 '12 14:07

Paul


2 Answers

Alternatively, you can use Bitmap.eraseColor() to set a solid color for your bitmap.

Example:

  import android.graphics.Bitmap;   ...   Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);   image.eraseColor(android.graphics.Color.GREEN); 
like image 188
theartofrain Avatar answered Oct 04 '22 20:10

theartofrain


I think I may have the answer. Technically I believe it is much easier on Android than on a "pc". The last time I searched to create a bitmap (.bmp), I only found some Android functions and the BitmapFactory for non-android, which didn't work for me.

Please look at this site: http://developer.android.com/reference/android/graphics/Bitmap.html
This point could fit for you:

static Bitmap createBitmap(int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

like image 24
AxP Avatar answered Oct 04 '22 19:10

AxP