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. PLEASE HELP: Android kernel patches for Linux 2.6.29-rc3 from Ti

Hello All,
I am trying to port Android on a custom made board based on omap 3530.
We used Linux os 2.6.29-rc3 from Ti on a reference board.

We have been able to boot the system to the Linux. Now I need to find
appropriate patches to the kernel to enable the Android on the board.

I have googled to figure out what I need to do, got these questions
1- The git tree that maintain all the Android development, which one
should I use? ie. omap, row-boat, ...?
2- How to extract the correct patches for the linux version that we
use (2.6.29-rc3)?

Many thanks in advance,



2. Can I use the Linux usbserial driver and ADB at the same time?

I was trying to connect to the serial port on the Android device from
the host PC. What I was doing was loading the "usbserial" driver:

modprobe usbserial product=<product id> vendor=<vendor id>

It seems it does recognize all serial functions in the USB and created
several ttyUSB ports/devices. However, it seems (at least on my
device) that the interface used by ADB is also picked up by
"usbserial", and because of that, I couldn't use ADB to connect to the
device until I unload usbserial.

Do you know if this is an issue? Is there a way to get both usbserial
and ADB to work?



3. building source code.

4. adding a new package to the android filesystem

5. Android and Kernel 2.6.33

6. Application that works on WAP connection

7. Motorola Droid - QCIF Camera Preview and Capture