problem about android-image-Collection of common programming errors


  • Binghammer
    android bitmap android-imageview android-image bitmapimage
    I have 1024 x 900 image coming from server. And I want to get the half of this image. I use this code img.setImageBitmap(Bitmap.createBitmap(bitmap,0,bitmap.getWidth()/2, bitmap.getWidth(), bitmap.getHeight()/2));But when I do this I have this error y+height must be <=bitmap.getHeightWhat should I do here for not getting the exception.

  • Atinder
    android android-layout android-image android-memory
    I am using an image to set as the background for all my activities but it was causing a memory overflow issue and crash the app. Now I am unbinding my drawables on pause() and on Destroy() in my activity and now it shows blank screen on pressing back button. So how can I avoid this without using extra memory.protected void onPause(){super.onPause();unbindDrawables(findViewById(R.id.login_root)); }protected void onDestroy() {unbindDrawables(findViewById(R.id.login_root));super.onDestroy();}privat

  • sebay
    android android-layout android-button android-image
    I’m trying to set an image of an ImageButton at runtime. It should fill the width of the screen and use as much space in height as it needs to scale correctly.The ImageButton is declared as followed:<ImageButtonandroid:id=”@+id/map_plan_topview”android:layout_width=”fill_parent”android:layout_height=”wrap_content”android:adjustViewBounds=”true”android:onClick=”onMapImageClicked”android:background=”#0000″android:scaleType=”fitXY” />Now I’m trying to set the image with:ImageButton topView =

  • rommex
    android jpeg android-image
    I need 6 large images in my app. And I don’t need the quality and alpha channel provided by PNG. Is there a way to embed JPEG files into the raw resource and unfold them into SD card at first launch of the program? It will save me 3-4 MB in my APK. Thanks!

  • chinmay dhodapkar
    android android-image
    I want to display a random image from the bunch of images i have stored in res/drawable.The only technique that I know is to access a particular image if you know its resource id. Is there a way to access the images by using the filenames or something else (which can be constructed at runtime)?I want to randomly select an image at runtime. Any suggestions/ideas appreciated :)Thanks Chinmay

  • chethan
    android android-layout android-listview android-image android-gridview
    I want to display a large number of images(say 500).i am currently displaying them in a scrollable grid layout by lazyloading images(very similar to fedor’s lazylist). but i am having issues while scrolling the grid. when i scroll the grid, the views get refreshed and the actual images are reloaded. so, even the images that were displayed earlier are refetched from SD card. this causes a very slow UI. is there any solutions for this.(i.e is there a way to tell the grid view not to refesh views o

  • mmBs
    android android-image android-bitmap
    In onActivityResult() in camera for picking the gallery image I am doing like this:Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri); where the imageUri file is of some 7.0MB so I am creating bitmap of smaller size where I am assigning it to same bitmap:bitmap=Bitmap.createScaledBitmap(bitmap,screenWidth,screenHeight/2, true)but the runtime memory is growing abnormally at that time where the memory allocated for 7.0 MB bitmap is not releasing, is GC not colle

  • n_yanev
    java android android-image
    I want to open one image from my assets folder, resize it and resave the image. I use this code:private void resizeImage(float ratio) {AssetManager assetManager = getAssets();InputStream stream = null;try {stream = assetManager.open(“bear.png”);} catch (IOException e) {return;}Bitmap bitmapOrg = BitmapFactory.decodeStream(stream);int width = bitmapOrg.getWidth();int height = bitmapOrg.getHeight();float scaleWidth = ((float) width) / ratio;float scaleHeight = ((float) height) / ratio;Matrix aMatr

  • eldarerathis
    android android-imageview android-image
    I’m saving an image from the device’s camera to a directory on the SD card (ex: /sdcard/appName/image.jpg), then I save the path into a database. My problem is that I can’t seem to load the images into a ListView with a cursor adapter.I tried the following code, where helper.getImg(); is a method from my database helper that returns a String (the file path), but it is not working.icon=(ImageView)row.findViewById(R.id.icon_pura); String imgPath=helper.getImg(c); Bitmap myBitmap=BitmapFactory.deco

  • The Coder
    android performance android-layout android-imageview android-image
    I am setting a background Image in my first activity which fits the complete screen in XML code only. From the first activity user navigates to another activity which does something from an image selected by a user. Now, my point is since the app loads an image for the user , is it feasible to remove the background image from first activity. And are there chances of app getting crashed if I don’t remove the background image while migrating to the second activity.

  • Jordan Wallwork
    android android-image
    I’m having a play with the android sdk for the first time, trying to get render some sprites from a spritesheet (.png), but the image is shrinking when I import it into the project – the image that I’m working from is 1330px wide, but when I run the app and output getWidth() it is showing as 998pxThis is causing errors because I’m trying to crop specific areas of the image and it keeps crashing with the exception java.lang.IllegalArgumentException: x + width must be <= bitmap.width()Can anyon

  • j0k
    android image-processing bitmap crop android-image
    I want to crop Red part from following image, Is there any simple method available in android that can crop following image.I have found many SO questions but all are suggesting to used following code:Bitmap croppedBitmap = Bitmap.createBitmap(bitmapOriginal, 100, 100,100, 100); This code work well if width & height are around 2MP resolution, but if that cropped part is more than 3MP resolution than application got crashed with OOM error.Is there any way that handle image more than 3MP durin

  • Raghunandan
    android bitmap android-image
    Hi I am trying to get an image from url to bitmap. I have android 4.1 device. When I run this code on new URL(). open connection().getInputStream()); app freezes then force close. Any idea?runOnUiThread(new Runnable() {public void run() {String url = “http://netmera.com/cdn/app/file/netmera.com/series/img-48/1372262272227_89/medium”;try {Bitmap bmp = BitmapFactory.decodeStream(new URL(url).openConnection().getInputStream());} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.

  • haythem souissi
    android fragment android-image
    I have a bug that seems crazy???I am starting a fragment from my activity.In the fragment I call startActivityForResult, trying to get image from gallery.Intent intent = new Intent(); intent.setType(“image/*”); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent,”Select Image”), SELECT_IMAGE);When I come back from gallery, my application crashed. I followed the problem and I saw that when I return to my activity I see that the onCreate() of my fragmen

  • user1851263
    android-image
    My app needs to list texts and images for one particular activity. Each row of the list has 2 columns – 1 for image and 1 for string.It works if the number of images is small (ten or less). When it exceeds 10 (sometime 15), the app will crash. How can make this work for more than ten images?Below are the codes for listing the texts and images. The first 2 lines retrieve the data from strings.xml. Thanks.pic=res.obtainTypedArray(R.array.site_pic);arr_site = getResources().getStringArray(R.array.

  • shakthivel
    java android bitmap android-image
    In my android application I have to allow the user to click a button to open the Gallery and to select an image. And then needs to load that specific selected image to an Image View in my layout(UI). and i have some code but it comes java.lang.outofmemory.Please anyone can help me?

  • Ethan Allen
    java android android-camera android-image
    When I take a picture with my device, this code is crashing on the inputStream = line with an error of java.lang.NullPointerExceptionprotected void onActivityResult(int requestCode, int resultCode, Intent data) {super.onActivityResult(requestCode, resultCode, data);Uri uriImage;InputStream inputStream = null;ImageView imvCover = (ImageView)this.findViewById(R.id.imvCover);if ((requestCode == CAPTURE_IMAGE) && resultCode == Activity.RESULT_OK) {uriImage = data.getData();try {inputStream =

  • iappmaker
    android android-canvas android-image
    I am testing the app on my phone (size 720×1280). The app runs fine when I use the sample size of 2. When I tried to use the sample size of 1 the app crashes in the line where I draw the image (code mentioned below). Please point me where my code need correction.canvas.drawBitmap(backgoundImage, 0, 0 , null); Codepublic Bitmap getAssetImage(Context context, String filename) throws IOException {AssetManager assets = getApplicationContext().getResources().getAssets();InputStream buffer = null;t

  • iappmaker
    android android-canvas android-image
    I am testing my App in the Emulator. Emulator Device Size – 480 x 854 Image size – 1280 x 720 Sample size = 1 (This is from the process explained in the Android reference – http://developer.android.com/training/displaying-bitmaps/load-bitmap.html)When I trigger this activity the App goes fine, When I traverse to next activity and come back, the App crashes with OOM. I have followed the process explained in the android manual for loading the bitmap efficiently, but still it fails in the linebackg

  • Maria Niaz
    android android-imageview android-image
    I am trying to get the scaled bitmap from an imageView because i need an image with height equal width so as to divide them later in equal smaller bitmaps. I am using the following piece of code: public void breakImage(View v){ImageView imageView = (ImageView) findViewById(R.id.imgView);Drawable d = imageView.getBackground();BitmapDrawable bitmapDrawable = ((BitmapDrawable) d);Bitmap image = bitmapDrawable .getBitmap();Bitmap scaledImage = Bitmap.createScaledBitmap(image, 240, 240, true);int w

  • sourcerebels
    android android-image
    A bitmap is captured and passed between Activity by declaring static. For the first time, the images can be displayed. However, when the second Activity is destroyed and created again, the image cannot be shown. The error is:04-30 12:55:28.988: W/dalvikvm(4034): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0) 04-30 12:55:29.028: E/AndroidRuntime(4034): FATAL EXCEPTION: main 04-30 12:55:29.028: E/AndroidRuntime(4034): java.lang.RuntimeException: Canvas: trying to use a recyc

  • iappmaker
    android android-layout android-image
    I have a splash screen which shows a image for 2 sec. The image is a PNG image. When I start my APP sometimes it crashes with the following error messages. The exact line where my app crashes is setContentView(R.layout.splash);key error lines : I could see there is some error with reference to java.lang.OutOfMemoryError while inflating the layoutCould you please let tell me where I need to correct my code.XML<?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://

Web site is in building