Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a implementation of the <em>doSomethingWithTHESEChannels</em> method as per your design :</p> <pre><code> private int doSomethingWithTHESEChannels(int i, int channels) { if (Channel.NONE == channels) { return i; } int a, r, g, b; a = (i &amp; Channel.ALPHA) &gt;&gt; 24; r = (i &amp; Channel.RED) &gt;&gt; 16; g = (i &amp; Channel.GREEN) &gt;&gt; 8; b = i &amp; Channel.BLUE; int cur = channels &amp; Channel.ALL; if (cur == Channel.ALL) { System.out.println("all found"); a = transform(a); r = transform(r); g = transform(g); b = transform(b); } else { cur = channels &amp; Channel.ALPHA; if (cur == Channel.ALPHA) { System.out.println("alpha found"); a = transform(a); } cur = channels &amp; Channel.RED; if (cur == Channel.RED) { System.out.println("red found"); r = transform(r); } cur = channels &amp; Channel.GREEN; if (cur == Channel.GREEN) { System.out.println("green found"); g = transform(g); } cur = channels &amp; Channel.BLUE; if (cur == Channel.BLUE) { System.out.println("blue found"); b = transform(b); } } return (a &lt;&lt; 24 | r &lt;&lt; 16 | g &lt;&lt; 8 | b); } </code></pre> <p>The transform method is the operation to be applied to a channel. The <em>Sysouts</em> are just for testing purposes. You may change the type of a,r,g,b variables to byte with proper type-castings if needed. </p> <p>However, I suggest you to move the above channel detection blocks(if conditions) to the <em>getProcessedPixels</em> method itself. Then you can pass the entire <em>pixels</em> array to a transform method. This way you will eliminate the redundant condition checks for each pixel. If you need hint on this, just leave a reply, I will update the answer.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload