Note that there are some explanatory texts on larger screens.

plurals
  1. POBitwise operations on a png and bmp give different results? (Same 32 bit ARGB representation)
    text
    copied!<p>I'm trying to replicate some image filtering software on the Android platform. The desktop version works with bmps but crashes out on png files.</p> <p>When I come to xOr two pictures (The 32 bit ints of each corresponding pixel) I get very different results for the two pieces of software. </p> <p>I'm sure my code isn't wrong as it's such a simple task but here it is;</p> <pre><code>const int aMask = 0xFF000000; int xOrPixels(int p1, int p2) { return (aMask | (p1 ^ p2) ); } </code></pre> <p>The definition for the JAI library used by the Java desktop software can be found <a href="http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/XorDescriptor.html" rel="nofollow noreferrer">here</a> and states;</p> <pre><code> The destination pixel values are defined by the pseudocode: dst[x][y][b] = srcs[0][x][y][b] ^ srcs[1][x][y][b]; </code></pre> <p>Where the b is for band (i.e. R,G,B).</p> <p>Any thoughts? I have a similar problem with AND and OR.</p> <p>Here is an image with the two source images xOr'd at the bottom on Android using a png. The same file as a bitmap xOr'd gives me a bitmap filled with 0xFFFFFFFF (White), no pixels at all. I checked the binary values of the Android ap and it seems right to me....</p> <p><img src="https://lh3.ggpht.com/_EW60jqE5_B0/Sj-9U6PQj2I/AAAAAAAAAFM/dSgxKyz85V0/s800/device.png" alt="Android"></p> <p>Gav</p> <p>NB When i say (Same 32 bit ARGB representation) I mean that android allows you to decode a png file to this format. Whilst this might give room for some error (Is png lossless?) I get completely different colours on the output.</p>
 

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