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. using java.sql instead of android.database

Can I use the standard java.sql API to query a sqlite database on
android?  I am working on an app that shares some code between the
client side (android) and server side (apache tomcat servlet) and I am
puzzled why the android documentation includes java.sql but no
information on how to use it to access android database with it.



2. startup sequence, how do i get from main to launcher.OnCreate()

Hi All,
I am new to android, I have done a few apps based on the examples

Now, I think it would be good for me to really understand the whole
android system. Therefore I imagine that to do that I can start  by
replacing the default main screen, the one where u can drag the clock
around and replace it with my own app, eg. calculator.

My understanding is that Launcher is the main activity that i have to
replace and stop from executing. Therefore i am thinking that if i
find where this thing is invoked, i can instead ask it to invoke my
calculator instead.

Please correct me if my understanding is wrong.

My question is as follow:
1. is there any good read that i can find regarding this? from what i
find on the net, they are mostly trying to teach us how to create
2. Is this the correct way to do this? or should it be just create an
apk which will never close and start during start up and cover the
main screen



3. Formatting text size and text color in ListView();

4. Is using google maps driving direction legal for android app for ADC II?

5. Hello Tutorials - Gallery Example

6. Downloading files from the browser

7. problem with Hello, Gallery R.styleable not resolve