Android :: Loading Only Part Of Bitmap File In Android

Mar 30, 2010

I would like to load a cropped version of a bitmap image into a Bitmap object, without loading the original bitmap as well. Is this at all possible without writing custom loading routines to handle the raw data?

Android :: Loading only part of Bitmap File in Android


Android :: Loading A Resource To A Mutable Bitmap

Sep 11, 2010

I am loading a bitmap from a resource like so:

Bitmap mBackground = BitmapFactory.decodeResource(res,R.drawable.image);

What I want to do is make some changes to the bitmap before It gets drawn to the main canvas in my draw method (As it would seem wasteful to repeat lots of drawing in my main loop when it isn't going to change). I am making the changes to the bitmap with the following:

Canvas c = new Canvas(mBackground);
c.drawARGB(...); // etc

So naturally I get an exception

java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor

So to avoid that I made a copy of the bitmap so that it is mutable

Bitmap mBackground = BitmapFactory.decodeResource(res,R.drawable.image).copy(Bitmap.Config.ARGB_8888, true);

Which avoid the problem however it sometimes causes OutOfMemoryExceptions, do know any better ways of achieving what I want?

View 2 Replies View Related

Android :: Optimizing Bitmap Loading By Using ASyncTask

Aug 4, 2010

I have been trying to optimize my single thread app which loads a bunch of tiles that makeup a large bitmap.The app was becoming very sluggish when it would load the new tiles into system memory.I'm now looking trying to use Async Tasks for this purpose. The app detects which tile is in the top left in a method called by onDraw, creates a string that contains the path of the bitmap in the Assets folder, and then checks to see if the bitmap is null before drawing. If it is null, it will load it into memory. My idea was to process the bitmap in DoBackground, and in postExecute trigger a view invalidate to display the async loaded bitmap. Few questions:

1.) can i execute my aSync task for each bitmap? (this statement: new myAsyncTaskManager().execute(bitmapPath); if not, what is the best way to go about it since the only thing aSync will do is just load bitmaps into memory?

2.) Is it possible to set the priority aSyncTask if the bitmaps load too slow?

3.) Is there a better way to go about this? im certain it is the bitmap loading, and not the canvas drawing that slows down the app.

My temporary aSync code:

private class myAsyncTaskManager extends AsyncTask<String, Void, String> {

@Override
protected String doInBackground(String... bitmapPath) {
Log.e("sys","i ran using aTask");
try {

bitmapArray[rectBeingDrawn] = BitmapFactory.decodeStream(assetManager.open(imagePathToLoad));

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} return null;
}

@Override
protected void onPostExecute(String result) {
// execution of result of Long time consuming operation
mCampusMap.invalidate()

View 2 Replies View Related

Android :: Loading An Alpha Mask Bitmap

Oct 28, 2010

I have a single-channel PNG file I'd like to use as an alpha mask for Porter-Duff drawing operations.If I load it without any options, the resulting Bitmap has an RGB_565 config, i.e. treated as grayscale.If I set the preferred config to ALPHA_8, it loads it as a grayscale ARGB_8888 instead.How can I convince Android to treat this file as an alpha mask instead of a grayscale image?

mask1 = BitmapFactory.decodeStream(pngStream);
// mask1.getConfig() is now RGB_565

BitmapFactory.Options maskOpts = new BitmapFactory.Options();
maskOpts.inPreferredConfig = Bitmap.Config.ALPHA_8;
mask2 = BitmapFactory.decodeStream(pngStream, null, maskOpts);
// mask2.getConfig() is now ARGB_8888 (the alpha channel is fully opaque)

View 1 Replies View Related

Android :: OutOfMemory Exception When Loading Bitmap From External Storage

Nov 5, 2010

In my application I load a couple of images from JPEG and PNG files. When I place all those files into assets directory and load it in this way, everything is ok:

CODE:..................

But when I try to load the exact same images from sd card, I get an OutOfMemory exception!

CODE:..............

This is what I get in the log:

CODE:...........

UPDATE: Tried both of these on real device - it seems that I can't load more than 12MB of bitmaps into whatever is called "external memory" (this is not an sd card).

View 7 Replies View Related

Android :: Resize Large Bitmap File To Scaled Output File

Jul 26, 2010

I have a large bitmap (say 3888x2592) in a file. Now, I want to resize that bitmap to 800x533 and save it to another file.I normally would scale the bitmap by calling Bitmap.createBitmap method but it needs a source bitmap as the first argument, which I can't provide because loading the original image into a Bitmap object would of course exceed the memory (see here, for example).Is there a way to read a large image file with 10MP or more and save it to a new image file, resized to a specific new width and height, without getting an OutOfMemory exception?I also tried BitmapFactory.decodeFile(file, options) and setting the Options.outHeight and Options.outWidth values manually to 800 and 533, but it doesn't work that way.

View 4 Replies View Related

Android :: How To Download Only First Part Of A .csv File On Droid

Nov 9, 2010

In my app, I have to present a few numbers from a .csv file that's accessible from the web. Now, this .csv is quite big. I don't want to download and process the whole thing, there's no point. My numbers are always in the beginning of the file, in well specified positions - lets say position 5 to 10.

Could you give me some tips on how to implement this? I know how to download the whole thing, but don't know how to download only a part of it.

View 3 Replies View Related

Android :: How To Display Some Part Of HTML File In WebView?

Apr 21, 2010

We have a large HTML which contents 1000's of lines. But we want to show content of the HTML file that fits a single screen. We want provide a '>' kind of to show the next contents of the same HTML file. Our objective is to only display the HTML contents that fits the screen.Similar to reader application For user, it seems there are several pages. Is there any way in which we can achieve this functionality. Whether WebView has any function related to full fill the requirement.

View 2 Replies View Related

Android :: How To Write Bitmap Out To XML File

Jan 21, 2010

Might sound crazy, but it's what I need to do. I want to take a Bitmap object and use the XMLPullParser/XmlSerializer to write this to a flat file. Obviously I will need to read the XML tag back into a Bitmap object.So somehow I have to turn my Bitmap into a String and then turn that String back into a Bitmap. I will do some searches on Base64 to see if I get any good examples.

View 2 Replies View Related

Android : Need To Create A New File ( To Be Sent ) From A Bitmap

Jul 30, 2010

I have a bitmap "picPrev" which I got from my online server. I want to turn it into a file so I can send it. I was exploring this method. code...

View 2 Replies View Related

Android :: Read File Into Java Bitmap?

Nov 4, 2010

I know how to read a bitmap file into a byte array. How is the byte array then converted to a Java Bitmap?

View 1 Replies View Related

Android :: How To Save A Bitmap Instance To A Bmp File?

Jun 27, 2009

How can i save a Bitmap instance to a *.bmp file?Anyone knows? Is it strange that we can only save a bitmap instance to a png or jpg file?

View 7 Replies View Related

Sprint HTC Hero :: Part Of Zip File Do I Put On Sd Card To Flash Rom?

Sep 12, 2010

I'm new to rooting and i just downloaded the fresh 2.4 rom for my cdma hero. do i put whole zip file on card or just the image. and where on the sd card should it go. i have already rooted.

View 4 Replies View Related

Android :: Load And Draw Partially A Bitmap From File

Sep 13, 2010

I have a somewhat large (i.e. not fit in most phones' memory) bitmap on disk. I want to draw only parts of it on the screen in a way that isn't scaled (i.e. inSampleSize == 1)

Is there a way to load/draw just the part I want given a Rect specifying the area without loading the entire bitmap content?

View 2 Replies View Related

Android : Get Bitmap Infomation Before Decode An Image File?

Jun 4, 2009

I want to know an image's width before decode it, so that I can set Options.inSampleSize if the image is too large. Any advice to do that?

View 3 Replies View Related

Android :: Loading From Compiled XML File

Jun 30, 2010

I have some xml files with a custom format (based on the scxml specifications) that I want my program to read. I've already written the code to read it, but I'm running into problems actually reading the file itself. I want the file to be compiled with the apk, as it will not be changed at all during run time. So I put the file (test.xml) in the res/xml/ folder, and got the inputstream by using:

getResources().openRawResource(R.xml.test);
But when I read in this inputstream it is complete jibberish, which makes me suspect it is being read in binary, as openRawResource() is often used for binary files like images, if I am correct. What is the correct way to do this?

View 11 Replies View Related

Android :: Dynamically Loading JAR File At Runtime

Mar 18, 2009

I am storing the required test.jar file in the /sdcard. I want to load it dynamically at runtime and want to execute a function xyz() resides in that. For this purpose I had written following code:
But got ClassCastException : dalvik.system.PathClassLoader

Following is my code ,
import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader;

import android.app.Activity; import android.os.Bundle; import android.util.Log;
public class Collabera extends Activity {
/** Called when the activity is first created. */
private static final Class[] parameters = new Class[] { URL.class };
public static void loadURLClass(String classPathURL) throws IOException {
File f = new File(classPathURL);
URL url = f.toURL();
URLClassLoader systemLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Class systemLoaderClass = URLClassLoader.class;
try { Method method = systemLoaderClass.getDeclaredMethod("addURL", parameters);
method.setAccessible(true);
method.invoke(systemLoader, new Object[] { url });
} catch (Throwable t) { t.printStackTrace();
throw new IOException( "Error, could not add URL to system classloader");
} }
@Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i("See","**************Before Loading Class Path**************");
try { Class.forName("test.Test1");
} catch (ClassNotFoundException e) { System.out.println(" Test Class Not Found ....");
} Log.i("See","**************After Loading Class Path**************");
try { loadURLClass("//sdcard//test.jar");
Class c = Class.forName("test.Test1");
Log.i("See"," Test Class Found ....");
Method method = c.getMethod("xyz", null);
Object o = c.newInstance();
String s = (String) method.invoke(o);
Log.i("See","Got method: " + s);
} catch (ClassNotFoundException e) { System.out.println(" Test Class Not Found ....");
} catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace();
} } }

View 9 Replies View Related

Android :: Loading HTML File On View

Nov 2, 2010

I have one html file and I want to load that html file in view for loading ping images. I was doing:
android:background="@drawable/tips"
This in xml file but how to load html file in view?

View 8 Replies View Related

Android :: Loading APK File On Device For QA / Testing

Sep 7, 2010

I'd love to get some ideas on best practices for testing our Android software, especially for AT&T devices. We're using a Samsung Captivate, on AT&T. As you know, AT&T disables sideloading (no Unknowns Sources option in Settings->Applications). We need to have our QA team load our apk file onto these devices as part of our testing and validation process. We're willing to install the SDK if needed, and upload the apk file via USB. We are not willing to root the phone.

View 2 Replies View Related

Android :: Loading More Than One Layout File For An Activity

Apr 29, 2010

How can we use more than one layout file. I have implemented a cutom dialog.That means i have created an layout file for dialog. And one layout file for my activity. But whatever the UI items in dialog layout ile if iam using them by findViewById it is giving me null

I will explain in details here @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); applicationContext=getApplicationContext();

Dialog folder=new Dialog(this); folder.setTitle("Creating folder"); folder.setContentView(R.layout.create_folder); TextView tv=findViewById(R.id.folder_text); //Here folder_text is in my second layoutfile ie in create_folder.xml //In the above statemet i got the null to tv variable. folder.show();

View 5 Replies View Related

Android :: Bitmap Image From File Does Not Scale On High Density Device / Display It?

Sep 24, 2010

I have problem with displaying bitmap image on imageview on high density screen (480x800). When the bitmap image loaded from file on sdcard, the image does not scale to fit hdpi screen. On medium density screen it works normal (320x480).code...

View 1 Replies View Related

Android :: Loading HTML File From SD Card In Web Browser

Jan 19, 2009

How to load simple html file present in sd mmc card from web browser. It is mentioned in the net that due to security reasons this is not allowed. Is there any way to access the file from sdcard? Tried modifying private String homeUrl =
"file:///sdcard/index.html";
in BrowserSettings.java file but browser throws an error "could not be loaded".

View 4 Replies View Related

Android :: Loading HTML File From Local RES Directory

Sep 29, 2010

This should be very simple, but I can't find the answer anywhere. How do I load an html file (which I assume I keep in res/raw folder) into a webview?
neither mWebView.loadUrl("file:///raw/about");
or
mWebView.loadUrl("file:///raw/about.htmal");
works.
What's the correct syntax or arrangement.

View 3 Replies View Related

Android :: Dynamic Loading Of Complete Layout File

Jul 1, 2010

I'm dealing with a problem you guys might not have faced earlier. I'm having a use-case in my Android application where the actual screen that I want to show to user is not stored in any layout file of my application. The layout of the of the screen is designed by server in this case, based on selection made by user on first screen.

Let me elaborate here,
1st Screen : List of check box with different biller names. (Imagine I've selected 2 billers from this screen)
2nd Screen : (The screen that server has decided how it should look like)
* Header,
* 1st Biller name (Label)
* Amount for 1st Biller TextBox
* Image (a Separator image)
* 2st Biller name (Label)
* Amount for 2st Biller TextBox.
* Here there can be a checbox/radio/another TextBox anything.
* Image (a Separator image)
* Button (to submit above form back to server)

I hope makes some sense in what I'm planning to design. The current issues I'm dealing with are as below.
1). How to draw this dynamic widgets?
2). How to fetch user Inputs from this dynamically created widgets?

View 3 Replies View Related

Android :: Loading 3D Models - OBJ File Into My Own Model Class

Mar 11, 2009

How are people here loading in their models? I'm just manually parsing a OBJ file into my own model class and drawing that.

View 4 Replies View Related

Android :: Loading Raw Resource Text File / Out Of Memory Error

Sep 15, 2010

I use this method couples of occasion to load text file to display as help file. But I don't know why the following code didn't work. It seems to hang and logcat says "OutOfMemoryError"? All I did was break this out as an separate activity.

---xml---
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/helptab"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/helptext"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</ScrollView>

---code---
import java.io.DataInputStream;
import java.io.IOException; import java.io.InputStream;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class Help extends Activity {
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
InputStream iFile = getResources().openRawResource(R.raw.help);
try { TextView helpText = (TextView) findViewById(R.id.helptext);
String strFile = inputStreamToString(iFile);
helpText.setText(strFile);
} catch (Exception e) {
} }
public String inputStreamToString(InputStream is) throws IOException {
StringBuffer sBuffer = new StringBuffer();
DataInputStream dataIO = new DataInputStream(is);
String strLine = "";
while ((strLine = dataIO.readLine()) != "") {
sBuffer.append(strLine + " ");
} dataIO.close();
is.close();
return sBuffer.toString();
}

View 6 Replies View Related

Android :: Loading External Data On Local File In WebView

May 27, 2009

when I load external web page, image or javascript file from local webpage. I can't see external image and can't load javascript or webpage. But I can only see local image. Why I can't load external javascript, webpage or image? Here is the HTML source. (of course, I filled right [daum open API key])

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta
http-equiv ="Content-Type" content="text/html;
charset=UTF-8"> <title>Daum 지도 API</title>
<script type="text/javascript"
src="http://apis.daum.net/maps/maps.js?
apikey=[daum open API key]" charset="utf-8"></script> </head> <body>
<div id="map" style="width:600px;
height:400px;
" style="border:1px solid #000">
</div> <img src="http://4.bp.blogspot.com/_2-7AdSkZA7I/RlCnDhD3ZfI/ AAAAAAAAE9U/LEHMtyVLdY8/s400/CutyTale10.jpg">
<img src="file:///android_asset/coffeebean.jpg">
<script type="text/javascript">
var map = new DMap("map", {point:new DLatLng(37.48879895934866, 127.03130020103005), level:2} );
</script> <iframe src="http://www.daum.com" width="300" height="150"></iframe> </body> </html>

and I use this Activity source
package bo.my.android.test;
import android.app.Activity;
import android.os.Bundle; import android.webkit.WebView;
public class OpenAPITest extends Activity {
WebView webView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView1);
webView.setWebViewClient(new DaumMapClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/daummap.html");
//webView.loadUrl("http://www.daum.net");
} }

View 3 Replies View Related

Android :: Loading String Values From File Instead Of List In Class

Nov 1, 2010

I think I have a pretty easy problem to solve, but I have been beating my head against the wall for hours trying to get past it! I have an adapter that loads a list of URLS:
adapter=new MyAdapter(this, lStrings);
list.setAdapter(adapter);

The list of URLS looks like this:
private String[] lStrings={
"http://www.domain.com/file1.jpg",
"http://www.domain.com/file2.jpg",
"http://www.domain.com/file3.jpg",
};

What I want instead is to load these values from a text file that lies on the SD card. For that matter, I would be okay with loading the values from a text file into a String, and then load the String into the list as I imagine that would be the "cleaner approach". However, all attempts to do this have failed. For instance, I replaced the above snippet with this:

private String[] lStrings=
{ MainActivity.this.getString(R.string.myurllist) };
but then I get a Forced Close on loading.

I'm a bit new to Java, Android, and development in general.

View 1 Replies View Related

How To Program / Write Code On Webview In Android For Loading HTML File

May 8, 2012

how to program/write code on a "webview" in Android for loading a html file?

View 2 Replies View Related

Android :: How To Create Bitmap From Image File In Android?

Mar 2, 2010

How to load an image file (on SD card) into a Bitmap on Android?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved