jpeg - How do I preserve all the original image data in a JPG in Android? -
i'm working client color style guides immutable, , part of app there feature jpgs provided sent server.
i'm converting images bytestream , uploading thusly, images arrive colors different original.
here's code byte stream creation...
bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap b = bitmapfactory.decoderesource(getresources(), uploadimgid); b.compress(bitmap.compressformat.jpeg, 100, stream); byte[] bitmapdata = stream.tobytearray();
i'm using 100% compression, so, i'm not sure why it's altering image in way.
would more reliable move jpgs device's file system , upload file? alternatively, more reliable use pngs instead of jpgs? (i'm guessing png treats color information differently jpg does).
tia
the executive summary seem taking bitmap , compressing using jpeg. jpeg lossy. if colours must kept right, need lossless codec, such png.
the long story follows:
jpeg lossy codec. compresses pictures loosing information in pictures humans not notice.
this can occur in 2 stages:
a common, although not mandatory step before jpeg compression chroma downsampling. name implies, involves loosing color information humans not sensitive to.
in addition, dct transformation, next , mandatory step in jpeg, works eliminating picture fine details humans wont notice. can, in pictures (such sharp edges) cause further color changes.
png on other hand lossless codec - works eliminating redundancy in information in image, never loosing information. comprised rle followed lempel ziv encoding, totally reversible.
in short, use png , save original colors beware pictures bigger uploading time longer , cellular data bill might bigger well.
Comments
Post a Comment