java - How to set pixels to a Bitmap in android properly? -
i want save pixelarray bitmap. got working except: app saves bitmap, colors little bit different in array.
this how save colors array:
bitmap bitmap = bitmap.createbitmap(width, height, bitmap.config.rgb_565); bitmap.setpixels(colors, 0, width, 0, 0, width, height); outputstream out = null; file file = new file(environment.getexternalstoragepublicdirectory(environment.directory_pictures).getparent(), "new.png"); try { file.createnewfile(); out = new fileoutputstream(file); bitmap.compress(bitmap.compressformat.png, 100, out); out.flush(); out.close(); mediastore.images.media.insertimage(getcontentresolver(), file.getabsolutepath(), file.getname(), file.getname()); } catch (exception e) { e.printstacktrace(); } this how set color pixel in array:
colors[0] = 0x287026; what goes wrong? compression png , store documents? because when go documents on phone , check new png created, it's little bit blurry. or bit of code wrong: bitmap.config.rgb_565? need use argb instead of rgb?
hope able me! :)
appreciated!
joeri
colors encoded ints, , can include alpha channel. suspect colors include alpha channel using argb colors when bitmap format calls rgb. change image format argb_8888 default , recommended format.
Comments
Post a Comment