bitmapfactory

Getting the size of an image inputstream

岁酱吖の 提交于 2019-12-01 22:18:47
问题 I need to get the height and width of the image found in the inputstream. Here is what I did: private Boolean testSize(InputStream inputStream){ BitmapFactory.Options Bitmp_Options = new BitmapFactory.Options(); Bitmp_Options.inJustDecodeBounds = true; BitmapFactory.decodeResourceStream(getResources(), new TypedValue(), inputStream, new Rect(), Bitmp_Options); int currentImageHeight = Bitmp_Options.outHeight; int currentImageWidth = Bitmp_Options.outWidth; Bitmp_Options.inJustDecodeBounds =

Android Bitmap from URL always null

心不动则不痛 提交于 2019-12-01 13:14:46
I'm trying to download an image from a URL and convert it into a bitmap, but the line Bitmap myBitmap = BitmapFactory.decodeStream(input); always causes the debugger to skip to the following line return null; without ever actually printing out the stack trace and the Exception variable also doesn't exist in the variables listed in the Debugger. I read a lot about how there might be issues with urls not actually leading to images, not well formated images and the like but it still has the same issue with a hardcoded image that I'm positive exists. public static Bitmap getBitmapFromURL(String

Android how to scale an image with BitmapFactory Options

社会主义新天地 提交于 2019-12-01 02:21:28
I want to decode an image from the SD card with BitmapFactory.decodeFile(path, options). I also want images that are larger than 2048x2048 pixels to be scaled down to at most 2048x2048 (maintaining the proportions). I could do this manually after getting the bitmap, but that would require allocating a large amount of bytes in addition to the ones already allocated. How should i set up my BitmapFactory.Options object to get that effect? Thanks jbowes Use BitmapFactory.Options.inSampleSize when you first load your image to get the size as close as possible to your target size, then use Bitmap

Samsung galaxy S4 image capture Issue

旧街凉风 提交于 2019-11-30 23:09:15
I am developing an Android Application. I created a custom camera class to capture images. It is working fine in som many devices but when i Tried it with Samsung Galaxy S4 it returns image with gray lins as shown. My Code is : ![`*public void surfaceCreated(SurfaceHolder holder) { frontCam = SharedUserPrefs.getSharedPrefData(AutoCapture.this, Constants.IS_FRONT_CAMERA); if (frontCam.equals(Constants.VALUE_ON)) { for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); camIdx++) { Camera.getCameraInfo(camIdx, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { try

How can I specify the bitmap format (e.g. RGBA_8888) with BitmapFactory.decode*()?

送分小仙女□ 提交于 2019-11-30 12:20:00
I'm making several calls to BitmapFactory.decodeFile() and BitmapFactory.decodeResource() , and I'd like to specify the format the bitmaps are decoded to, such as RGB_565 or RGBA_8888. Currently, the decoded bitmap format seems to depend on the incoming image. Alternatively, is there a way to convert an existing bitmap to a specific format? The reason this is important is that when I try to decode the image using jnigraphics , some images return an AndroidBitmapFormat of type ANDROID_BITMAP_FORMAT_NONE , which I assume is useless. Does anyone have more insight into why the format would be none

Printing an Image using a Bluetooth Thermal Printer From an Android App?

一个人想着一个人 提交于 2019-11-30 07:27:37
I have been trying to get a print of an Image but I have not been successful so far. The printer is a locally manufactured 2" thermal printer having a printing resolution of 8dots/mm, 384dots/line, 203 dpi. The printer is based of a board having the "NXP 2388 ARM v7 Microproc." having a Memory FLASH size of 512 KB, RAM: 128 KB & a Receive Buffer Size of 16KB. I followed this question till now. Problem: The image I tried printing is of 576x95 res. The image got printed(with some error LED lighting up and debug buzzer noise :D) but the orientation of the image was vertical instead of getting

Converting Bitmap in memory to Bitmap with Bitmap.Config.RGB_565

泪湿孤枕 提交于 2019-11-30 03:26:28
I have a loaded Bitmap which I would like to convert to set the config to Bitmap.Config.RGB_565 . Is there a simple way of converting a Bitmap to this configuration after the Bitmap is already loaded into memory? For example, below I have a bitmap being decoded from the application resources, however, how would I convert an already loaded Bitmap to RGB_565 ? I'm sure it's something simple, however, I'm fairly new to working with Bitmaps and after a few hours of looking online, unfortunately I couldn't find what I needed specifically. BitmapFactory.Options options = new BitmapFactory.Options();

Image from gallery rotates automatically - Android

耗尽温柔 提交于 2019-11-29 15:10:51
问题 In my android application i am loading image from device gallery.In that, i am facing issue regarding image orientation. When i load large resolution images from gallery, they are automatically rotated then display in my view. I tried various solution regarding this problem but couldn't get proper solution. I referred getOrientation() , and this links. I have tried both solutions but couldn't got desired result.The ExifInterface return proper data but then also they are not helpful as images

Image isn't creating using the BitmapFactory.decodeByteArray

一世执手 提交于 2019-11-29 14:43:38
Edit: When I save those bytes in the txt file and when I save it as png file , it shows the image, but it is not working here why...? I am using this code to create image from byte array on doInBackground() String base64data=StringEscapeUtils.unescapeJava(IOUtils.toString(resp.getEntity().getContent())); base64data=base64data.substring(1,base64data.length()-1); JSONObject obj=new JSONObject(base64data); JSONArray array=obj.getJSONArray("EMRTable"); JSONObject childobj=array.getJSONObject(0); results=childobj.getString("DocumentInternalFormat"); and onPostExecute if(jsondata!=null) {

Printing an Image using a Bluetooth Thermal Printer From an Android App?

◇◆丶佛笑我妖孽 提交于 2019-11-29 09:45:30
问题 I have been trying to get a print of an Image but I have not been successful so far. The printer is a locally manufactured 2" thermal printer having a printing resolution of 8dots/mm, 384dots/line, 203 dpi. The printer is based of a board having the "NXP 2388 ARM v7 Microproc." having a Memory FLASH size of 512 KB, RAM: 128 KB & a Receive Buffer Size of 16KB. I followed this question till now. Problem: The image I tried printing is of 576x95 res. The image got printed(with some error LED