Scamble a Bitmap image

by John Woods » Wed, 12 May 2010 15:13:07 GMT

Sponsored Links
 I am new to android development. I have been asked to write an
function to scramble a bitmap image. A user can then enter a password
and the image will unscramble.

I have managed to write the following code that works but takes way to
long to execute due to the setPixels call.

I was thinking of an alternate solution of just drawing the original
unscrambled image and then making some sort of transparent overlay
bitmap with some sort of distortion effect. When the user enters the
correct password the overlay fades away.

Please help!

protected void onDraw(Canvas canvas)
        //Some of the variables are global but I left out that code. This
successfully runs.

                int w = bitmap.getWidth();
        int h = bitmap.getHeight();

        Bitmap scrambled = Bitmap.createBitmap(w, h,
        int[]pixels = new int[w*h];

        bitmap.getPixels(pixels, 0, w, 0, 0, w, h);

        int color = 0;
        Random random = new Random();

        Paint paint = new Paint();

        for (int i = 0; i < pixels.length; i++)
                pixels[i] = pixels[random.nextInt(pixels.length - 1)];

        scrambled.setPixels(pixels, 0, w, 0, 0, w, h);
        canvas.drawBitmap(scrambled, 0, 0, paint);


Other Threads

1. How was the conference - man i wanted to go

I read that all you lucky developers who attended got the developer
phone with Donut on it.  How was the content of the workshops?   How
was it overall?


2. Who is making money in the Android Market?

A lot of big players are not building apps for Android because they
don't see any money in it. What applications are making money and what
model are they using, ad revenue, subscription, other?

If we want more apps in the Android Market monetization needs to be

Any feedback here is appreciated.

3. ListView: Default highlight the item

4. problem starting emulator from command line

5. Is it possible to include the cupcake plugins jar into my app?

6. Android 1.5 - getNeighboringCellInfo() always returns 0 neighboring cells

7. Unable to initialize Repo client