Android_tutorial_image_transport displays strange image
Hi, I want to use a sample package of rosjava.android ,"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 BitmapFromCompressedImage.java 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?
@Override 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(Color.blue(pixel), Color.green(pixel), Color.red(pixel)); } } bitmap_output.setPixels(pixels, 0, Width, 0, 0, Width, Height); return bitmap_output; //return BitmapFactory.decodeByteArray(data, buffer.arrayOffset(), buffer.readableBytes()); }