开发者

discripencies while compressing a bitmap on Google nexus

开发者 https://www.devze.com 2023-01-03 20:37 出处:网络
I am compressing a bitmap object to OutputStream using \"Compress\" function. Here is my code: try { if (bitmap != null) {

I am compressing a bitmap object to OutputStream using "Compress" function. Here is my code:

try {
                    if (bitmap != null) {
                        bitmap.compress(Bitmap.CompressFormat.JPEG, 100,
                                bytes);
                    } else {
                        Message message = handler.obtainMessage(1, "false");
                        handler.sendMessage(message);
                        return;
                    }
                } catch (OutOfMemoryError oom) {
                    System.gc();
                    Message message=handler.obtainMessage(1,"false");
                    handler.sendMessage(message);
                    return;
                } catch (NullPointerException npe) {
                    System.gc();
                    Message message = handler.obtainMessage(1, "false");
                    handler.sendMessage(message);
                    return;
                } catch (Exception e) {
                    System.gc();
                    Message message = handler.obtainMessage(1, "false");
                    handler.sendMessage(message);
                    return;
                }

when i am开发者_如何学Go running this code on G1 and hero, i am getting a proper output stream( which i later save to a image file on sdcard). But when i test this code on Google nexus, i am getting a blurry image after converting the output stream in an image file.

FYI

OS: Android 1.5; G1 and Hero are on 1.5 OS and nexus is on 2.0

Please help.. is there a known issue in nexus?? or am i doing something wrong??


Check Game Development for Android: A Quick Primer.

From Step Three: Carefully Design the Best Game Ever:

The problem with texture compression is that different graphics card vendors support different texture formats. The G1 and other MSM7k devices support ATI’s ATITC compression format. The Droid supports PowerVR’s PVRTC format. Nvidia’s Tegra2 platform supports the DXT format. The bad news is, these formats are not compatible. The good news is, all OpenGL ES 2.0 devices (including the Snapdragon-based Nexus One, the OMAP3-based Droid, and Tegra2 devices) support a common format called ETC1. ETC1 isn’t the best texture format (it lacks support for alpha channels), and it isn’t supported on the first generation devices, but it’s the most common format supported (the Android SDK provides a compressor utility (see sdk/tools/etc1tool) and runtime tools for this format).

0

精彩评论

暂无评论...
验证码 换一张
取 消