java - How to split R,G and B channel each to double array and process it with Android Bitmap -
I Android and new with Java, and still evolving image watermarking application with Android DWT - DCT - Sveedi method I am doing I want to process R, G, B channels separately in a double type array.
This is my code:
// Using the intent, obtain the image from the album and pass the path to the variable string picture, cursor cursor = getContentResolver (). Query (photoUri, empty, null, null, void); Cursor.moveToFirst (); Int index column = cursor.gate column index (mediastore.images image column.data); PicturePath = cursor.getString (index column); Bitmapfile Option opt = new bitmap feature. Option (); Opt.inDither = false; Opt.inScaled = false; OptInDensity = 0; OptInJustDecodeBounds = False; Opt.inPurgeable = false; OptInSampleSize = 1; OptInScreenDensity = 0; Opt.inTargetDensity = 0; SourceHostBitmap = Bitmapfinder Esedaphile (painting); After googling for some time, I found that after the decoded image, I put the value for intArray like this: integer intArray = new brick [Sursehosbitmpkgetvidth () * Sursehosbitmpkgetheigt ()] Sursehosbitmpkgetpiksels (Intrry, 0, Sursehosbitmpkgetvidth (), 0, 0, Sursehosbitmpkgetvidth (), Sursehosbitmpkgetheigt ());
From this point, I do not know how to separate the three array R, G and B intersea. Please help me fulfill this, thank you
Edit: With Martin's exponent explanation, if I am right then I can write code like below to get the R, G, B value of the image in double-type array.
Double [] valueRed = new double [hostwidth * host hete]; Double [] valueGreen = new double [hostwidth * hosthit]; Double [] valueBlue = new double [hostwidth * hosthit]; For (int i = 0; i & LT; intArray.length; i ++) {valueRed [i] = (double) ((intArray [i] & amp; 0x00FF0000) & gt; & gt; 16); Price green [i] = (double) ((intere [i] and 0x0000FF00)> 8); ValueBlue [i] = (double) ((intArray [i] & amp; 0x000000ff)); }
Edit again: the @Martin suggestions, I value a duplicate bitmap with alpha = 100, red = 99, green = 98, blue = hex = 0x64636261 97 will make it (reminder: format stored in 0xAARRGGBB) to
(int i = 0; i & LT; intArray.length; i ++) {intArray [i] = 0x64636261; }
and then access each channel value in the random index:
int alpha, red, green, blue; Alpha = (inters [0] and 0xFF000000) & gt; & Gt; 24; Red = (intere [1] and 0x00FF0000) & gt; & Gt; 16; Green = (intersection [2] & amp; 0x0000FF00) & gt; & Gt; 8; Blue = (intersection [0] and 0x000000 FF); // Put it on TextView TextView TV = New TextView (R.id.tv); Tv.setText (alpha + "+ red +" "+ green +" "+ blue);
And the return value is the same as I imagine alpha = 100, red = 99, green = 98, blue = 97, try it!
Well, at that point you "rounded" S, where each integer (0xAARRGGBB) "A = Alpha" , "R = Red", there is an array of "G = Green" and "B = Blue", each color takes two bytes, therefore, you can do something like this:
First, use a mask to separate only bits, close all other bits:
Pixel & amp; 0xFF000000 / // Most important 8-bit (alpha) pixels and different; 0x00FF0000 // Split the next 8-bit (red) pixels & amp; 0x0000FF00 // Split next 8-bit (green) pixels & amp; 0x000000FF // Separate at least significant 8-bit (blue) then at least to store in B, Bit, B, C, and D (an unsigned bitsoft) Make changes to important bits:
(pixels and 0xFF000000)> gt; & Gt; & Gt; 24 // SHIFT BITS 24-31 BITS 0-7 Actual value of alpha (pixels and 0x00FF0000) & gt; & Gt; & Gt; 16 // Bits 16-23 to the actual value of bits 0-7 bits (pixels and 0x0000FF00) & gt; & Gt; & Gt; 8 // bits bits 8-15 bits 0-7 actual value of green (pixels and 0x000000 ff) // Do not need to replace the previous one! Blue's real value Hope it will lead you towards the right direction.
Regards!
Comments
Post a Comment