Android :: Image Scaling By BitmapFactory.decodeResource()

Sep 17, 2009

I can't wait to try out the new 1.6 goodies, but first I'm retargeting my existing applications, and I decided to start with Daisy Garden. Changing to android:targetSdkVersion="4" caused the application to segfault on startup and discovered that the BitmapFactory.decodeResource method now performs scaling based on screen density. In this case the behaviour is unwanted - I'm loading a set of masks that are scaled later during composition. So I've quickly inserted the following method, which seems to perfectly mimic the previous behaviour:

private Bitmap loadBitmap(int resId) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inTargetDensity = 1; options.inDensity = 1; return BitmapFactory.decodeResource(context.getResources(), resId, options);
}

Android :: Image scaling by BitmapFactory.decodeResource()


Android :: BitmapFactory Image From ZipFile

Aug 8, 2009

basically what i'm attempting to do is place several images into 1 zip file, and then read the images back out of the zip file, and draw them onto a canvas using BitmapFactory. This is what my code looks like, but when i debug i only get a source not found error.

Code: try {..............

View 2 Replies View Related

Android :: High Quality Image Resizing / Scaling

Nov 17, 2010

I need to scale down images coming from a Network stream without losing quality. I am aware of this solution Android: Strange out of memory issue but it is too coarse - inSampleSize is an integer and does not allow finer control over the resulting dimensions. That is, I need to scale images to specific h/w dimensions (and keeping aspect ratio). I dont mind having a DIY bicubic/lancoz algorithm in my code but I cant find any examples that would work on Android as they all rely on Java2D (JavaSE). EDIT: Ive attached a quick source. The original is 720x402 HD screen capture. Please ignore the top 2 thumbnails. The top large image is resized automatically by android (as part of layout) to about 130x72. It is nice and crisp. The bottom image is resized with API and has severe artifacting. Code...

View 1 Replies View Related

Android :: Threaded BitmapFactory Image Decoding

Oct 15, 2010

Our Android app does a lot of image decoding. We fetch a lot of images from the internet, local storage caches, etc. Up to now, these images are being decoded on the UI thread (using BitmapFactory.decodeX() methods). It's been causing some timeout crashes because the UI doesn't respond quickly enough to user input.

I could write a little AsyncTask that encapsulates decoding, but I'm not sure that's a good idea. Spawning threads is expensive, and that would be spawning and tearing down a ton of them. So what's the best way to put this on another thread? Do I need to go to the extent of writing a Service? That seems a little heavy-weight. Are there any solutions for this already out there?

View 2 Replies View Related

Android :: BitmapFactory.decodeFile Returns Null Even Image Exists / Why Is So?

Aug 2, 2010

Saving the file code...

The last line gives a null pointer exception, why is BitmapFactory.decodeFile returning null? I can verify that the file is getting saved correctly as I can pull it using adb and see the png displaying properly.

View 1 Replies View Related

Android : Maximum Size That VM Allocate For Loading A Image With BitmapFactory?

Mar 1, 2010

Some of you may met the same problem, I was using BitmapFactory.decodeStream, and got this exception: Code...

I know the reason is because the BitmapFactory is trying to decode an uncompressed version of a big image(in my situation, jpg). I can use BitmapFactory.Options.inSampleSize to fix it. but my question is what's the maximum size that VM would like to allocate for loading a image with BitmapFactory? so I can do some scale before it loads.

View 2 Replies View Related

BitmapFactory - (decode Returned False) For Internal Image Files Extracted From Zip

Apr 19, 2012

Need to display images downloaded and extracted from a zip into the "/files" directory of the app. the images are getting in there properly as far as i can tell - i am able to extract them from the emulator and view/open them from my desktop. but every attempt, every variation of code i have found and tried so far has failed (Tag: skia / Text: --- decoder->decode returned false).

My latest construct, which does work for image files downloaded separately and uncompressed :

Code:

String imgFile = new File(getFilesDir(), "myImage.jpg").getAbsolutePath();
ImageView myImageView = new ImageView(this);
Bitmap bm = null;
try{
bm = BitmapFactory.decodeFile(imgFile);
myImageView.setImageBitmap(bm);
} finally{
mainLayout.addView(myImageView);
}

And here is the construct i am using to handle the zip extraction. I assume this is where the problem lies but i am clueless as to what i could possibly do differently and to what effect:

Code:
ZipInputStream zis = new ZipInputStream(fis);
BufferedInputStream in = new BufferedInputStream(zis, 8192);
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null){
File dest_file = new File(getFilesDir(), ze.getName());

[code]....

View 2 Replies View Related

Android :: How To Fix Hit Area After Scaling?

May 11, 2010

I am scaling the canvas of a linear layout on draw, but this throws off all the hit areas of my views inside of this layout. They respond as if there was no scaling taking place. What do I have to do to get themselves to re-register their hit areas?

View 4 Replies View Related

Android :: Scaling Transparent Graphics In 2.0.1

Dec 13, 2009

I have some transparent graphics in my game. Up through 2.0.0 they have looked fined. Since Android 2.0.1 though, some parts of the fully transparent regions of the graphics are instead slightly opaque (e.g. a circular gradient that goes to 100% transparency will have a faint halo around it).

I have tried putting my graphics in ../raw/ but that did not help (as described at http://developer.android.com/guide/topics/graphics/2d-graphics.html#d...)

I have also tried exporting the Adobe Illustrator graphics at 16-bit pngs (instead of 8bit), but that did not help either.

View 2 Replies View Related

Android :: OpenGL Texture Scaling

Feb 18, 2010

I have a texture with 8 equally sized stripes that I am using as a wall with OpenGL. On my Nexus One it scales it properly However, in emulators and on a G1 (and probably on other hardware), it does not scale properly, as the stripes remain the same width, while the height scales as it should. Is there an option that I need to set that is set to default on my nexus one but not on other platforms?

View 3 Replies View Related

Android :: Nine Patch Pre-scaling On Hdpi

Jan 5, 2010

I have some 9-patch images on my app, and they work great on the medium density. When I load the app on a High density emulator/device, these images look grainy. It happens only to 9-patch images. The others look great after the pre- scaling. Is there a way to make them look good after the scaling, like the non-9-patch images?

View 10 Replies View Related

Android :: Avoid Scaling Of Background

Oct 15, 2010

In a start activity of our android application we're using a linearlayout with an background image for whole space. The image size is 320x480 - the same as device resolution, we're using for testing. The problem is, the image will be scaled und looks not so nice. I tried to use imageview instead, but I've got black borders.
Some ideas, how to avoid scaling or how to get the proper size for background image?!

View 1 Replies View Related

Android :: Disable Scaling Of ImageView?

Jun 22, 2010

Most of the time, Android scaling is nice but I have a case where I don't want any scaling and I can't find how to do this.

I made a simple layout to test code...

View 4 Replies View Related

Android :: Scaling TextSize In A TextView?

Feb 19, 2010

Say I have a TextView of a particular size (doesn't really matter what... fill_parent, 20dip, whatever). Is it possible to tell the text to shrink/grow in size to fit the available space without doing a lot of math?

View 2 Replies View Related

Android :: OutOfMemoryError From BitmapFactory

Apr 28, 2009

Like many others here I'm getting OutOfMemoryError from BitmapFactory when decoding multiple bitmaps. I am sure I am not leaking memory. Here is the system log from a crash:............

View 23 Replies View Related

Android :: Use BitmapFactory Optimisation

Nov 5, 2010

In my app, I am creating a bitmap from its colors code like this :

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

And often I get the outofmemoryerror: So how can I use the BitmapFactory optimisation to avoid this problem? because I don't have an input stream or a file, I only have an array containing my pixels.

View 1 Replies View Related

Android :: WebView Not Respecting Scaling Percentage

Jun 11, 2010

I have a WebView which I'm trying to have scale to a certain percent on loading the page. The iPhone version of this software uses the HTML meta-tag:<meta name="viewport" content="width=320, initial-scale=0.95, maximum-scale=2.0, user-scalable=1">..Since Android's WebView doesn't seem to respect that tag I hard-coded the percent using setInitialScale(). However, the WebView is just flat-out ignoring this method call. No matter what number I put in there it shows at 100%.

View 5 Replies View Related

Android :: Scaling Web Page In WebView Element

Nov 30, 2009

I'm loading a URL into a WebView and I'm having difficulty setting the "scale" of the web-page. Specifically, the web-page is too big (800x600) for the screen, so my thought is to use "setInitialScale(50)" to reduce the size. Here is some sample code that doesn't work (i.e. the web-page doesn't scale to 50%)

WebView wv = (WebView)findViewById(R.id.webview);
wv.loadUrl("http://www.example.com/android/symptom");
wv.setInitialScale(50);
I also tried switching the order of the function calls but I get the same resultŠi.e.,
WebView wv = (WebView)findViewById(R.id.webview); wv.setInitialScale(50); wv.loadUrl("http://www.example.com/android/symptom");

As an alternative, I have tried to use the "zoomOut()" function like this:
WebView wv = (WebView)findViewById(R.id.webview);
wv.loadUrl("http://www.example.com/android/symptom"); wv.zoomOut();
This approach works for a split second, and then the image reverts to its original size.

Here is my content view:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"> <WebView android:id="@+id/webview"
android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>

View 2 Replies View Related

Android : Does Phone Set - Support Scaling Video

Jan 14, 2010

Using a VideoView is it possible to set a scale factor for Android? By Default the video view resizes itself to fit the encoded resolution of the Video. Can I force Android to render a video into a smaller or larger rect?

View 3 Replies View Related

Android :: OutOfMemoryError At BitmapFactory.decodeByteArray

Jun 9, 2009

I get a OutOfMemoryError at BitmapFactory.decodeByteArray when bitmap size is large; Following is the code snippet:

BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 8; Bitmap bitmap = null; bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);..........

View 3 Replies View Related

Android :: Game Development Scaling - Texture And World

Jun 26, 2010

We're looking for a method to properly scale our textures and world. The current method we're using is having an arbitrary world unit which calculates the screen resolution and receives the size of a pixel on all resolutions. However is there an easier way of implementing a scaling method for game development? We have looked through dip and other android native elements but these don't work as well for a larger scale on game development.

View 3 Replies View Related

Android :: Scaling Game Images According To Display Sizes

Jan 6, 2010

I developed a game with the g1 in my mind. Now I want to support large screen sizes but I don't want to add in the apk different images for different screen sizes because now the apk is 3mb and when installed thought market it became 6mb (due to protection on). If I have to double the images to support new screens, the apk would be too heavy (about 13mb, I think) so I'm wondering to know if scaling images at runtime by myself (without compatibility mode) maybe the best way for supporting larger screens. Compatibility mode does a great work in scaling images but it slows down drastically the frame rate (I think because the scale operation is made every time an image is used/moved and not only once on the load of the image itself).

View 7 Replies View Related

Android :: Scaling - Animating Camera Preview Surface

Sep 20, 2010

I am using android.hardware.Camera to get a preview and display it on a custom SurfaceView that implements SurfaceHolder.Callback.

I am trying to zoom in to the camera preview surface by a specified scale (not using the camera's digital zoom) but I can't seem to find a correct way to do it. I also need to be able to zoom out and scale down the preview.

I was hoping to be able to do this using a ScaleAnimation but it doesn't seem to work on SurfaceView, nor the FrameLayout containing the SurfaceView.

I also tried setting the size of the SurfaceView using setLayoutParams but that doesn't seem to work too well on various hardware and it would be tough to animate smoothly.

How to achieve this effect? Right now I am starting to think I might have to implement this using GLSurfaceView but I'm very unsure.

View 2 Replies View Related

Android :: BitmapFactory.decodeStream Returns Null

Oct 3, 2009

I have an activity which performs an image search, the results (URLs of thumbnails on the web) are rendered in a GridView. My GridView adapter class delegates creating the actual Bitmaps to an AsyncTask that loops to sequentially fetch the image content from each URL using HTTPClient, and creates the Bitmaps using:

BitmapFactory.decodeStream(entity.getContent()).

I found that the above method sometimes returns "null" silently instead of creating a Bitmap. The occurrences appear to correlate with larger stream sizes (I check this by logging entity.getContentLength()). However, if I put a breakpoint just prior to the decodeStream call & then resume immediately every time I hit it (i.e. pause briefly on each iteration), the Bitmaps are created perfectly every time. All the images are quite small (most <10K), so the download & decodeStream happens fairly quickly. There are never more than 10 images processed in one AsyncTask.

View 6 Replies View Related

Android :: BitmapFactory.decodeStream Thread Safe?

May 7, 2010

Is the BitmapFactory.decodeStream method thread safe?

View 2 Replies View Related

Android :: BitmapFactory.decodeByteArray Gives Pixilated Bitmap

Jan 30, 2010

I am working on an app that displays photos which are downloaded from Flickr. I obtain a Bitmap object from a byte array, which in turn is read from the relevant Flickr URL, as follows: Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); The problem is that the resulting bitmap is pixelated and I can't figure out why. To demonstrate, here is an example of a picture created via BitmapFactory.decodeByteArray versus the original picture obtained directly from the relevant Flickr URL:...

View 6 Replies View Related

Android :: Out Of Memory Error In BitmapFactory.decodeFile

May 22, 2009

I was reading in some other posts that some developers have the same Problem, but till now, no solution. its about the gallery: I have a string array with photos, but when the gallery does show the 2nd Picture it crash with:...............

View 7 Replies View Related

Android :: BitmapFactory.decodeByteArray() Returning NULL

Jul 26, 2010

I am using the previewCallback from the camera to try and grab images. Here is the code I am using

private Camera.PreviewCallback mPrevCallback = new Camera.PreviewCallback()
{
public void onPreviewFrame( byte[] data, Camera Cam ) {
Log.d("CombineTestActivity", "Preview started");
Log.d("CombineTestActivity", "Data length = "
+ data.length );
currentprev = BitmapFactory.decodeByteArray( data, 0,
data.length );....................................

View 1 Replies View Related

Android :: BitmapFactory.Options - Exceeds VM Budget

Nov 5, 2010

I've been reading about performance issues decoding Bitmaps and have received the OutOfMemoryError "Bitmap exceeds VM budget" issue when I would expect to not be out of memory and read online that this is a common problem referred to as a bug in the framework by many devs. Typically, I get the error mentioned above on my second pass. Let's say I load a somewhat sizable Bitmap successfully and then recycle it and even set the ref to null. When I call this same method a second time that does the work of loading my Bitmap(s) into memory...

I've read on previous posts here and elsewhere online that there are a few things that can be done with BitmapFactory.Options (for instance, providing an input buffer explicitly). But, before proceeding blindly in using what I've found, I'm hoping someone with more knowledge of these classes can shed a little more light...........

View 1 Replies View Related

Android :: BitmapFactory.decodeByteArray Returns Null

Aug 18, 2010

In my application I am converting base64 string to image.For that I initially converted base 64 file to byte array and later am trying to convert to images.
To convert to Images I am using the below code

File sdImageMainDirectory = new File("/data/data/com.ayansys.Base64trial");
FileOutputStream fileOutputStream = null;
String nameFile="Images";
try {.......................

View 1 Replies View Related







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