Ask Your Question

Android_tutorial_image_transport displays strange image

asked 2012-10-05 00:03:06 -0500

KazutoMurase gravatar image

updated 2012-10-08 18:22:14 -0500

Hi, I want to use a sample package of ,"android_tutorial_image_transport".

This package subscribes ros messages which content is compressed image data. But the android screen displays strange image because ros began to publishe BGR data from f-turtle. So, I rewrite in android_gingerbread_mr1 as follows to transfer BGR data to RGB data.But it takes too much time.

What should I deal with this problem?

  public Bitmap call(sensor_msgs.CompressedImage message) {
    ChannelBuffer buffer = message.getData();
    byte[] data = buffer.array();
    Bitmap bitmap =BitmapFactory.decodeByteArray(data,buffer.arrayOffset(),buffer.readableBytes());

    final int Width = bitmap.getWidth();
    final int Height = bitmap.getHeight();
    Bitmap bitmap_output = Bitmap.createBitmap(Width, Height, Bitmap.Config.ARGB_8888);
    int[] pixels = new int[Width*Height];
    bitmap.getPixels(pixels, 0, Width, 0, 0, Width, Height);
    for(int x = 0; x < Width; x++){
        for(int y = 0; y < Height; y++){
            int pixel = pixels[x + y * Width];
            pixels[x + y * Width] = Color.rgb(,,;
    bitmap_output.setPixels(pixels, 0, Width, 0, 0, Width, Height);                                            
    return bitmap_output;
    //return BitmapFactory.decodeByteArray(data, buffer.arrayOffset(), buffer.readableBytes());                                                                
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-10-10 05:30:41 -0500

damonkohler gravatar image

I suggest changing your incoming image to one that the BitmapFactory supports. See

I believe you'll always run into one performance issue or another otherwise.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-10-05 00:03:06 -0500

Seen: 255 times

Last updated: Oct 10 '12