Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Read JPEG from SD card and display in ImageView

Read JPEG from SD card and display in ImageView

All your problems with Audio, Video and Images.

Read JPEG from SD card and display in ImageView

Postby jbrohan » Thu Sep 24, 2009 8:49 pm

This is a project I've been struggling with and now it works. I'm publishing the TestImageLoad.java and main.xml

The file on the sd card is named in a constant, which is ok for my app. There are some options for the bm = BitmapFactory.decodeStream(is, null, null); function but I am ignoring them.

<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Test Image Load"
/>
<ImageView android:id="@+id/picview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

The TextView is non functional.

TestImageLoad.java
package com.example.testimageload;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.ImageView;

public class TestImageLoad extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

File f = new File(Environment.getExternalStorageDirectory()+"/photo.jpg"); // or "/sdcard/photo.jpg"
FileInputStream is = null;
try {
is = new FileInputStream(f);
} catch (FileNotFoundException e) {
Log.d("John: ", "file Not Found");
}

Bitmap bm;
bm = BitmapFactory.decodeStream(is, null, null);
ImageView pic=(ImageView)this.findViewById(R.id.picview);
pic.setImageBitmap(bm);
}
}
jbrohan
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Aug 28, 2009 11:12 am
Location: Montreal

Top

Postby azraeal » Tue Sep 29, 2009 8:36 pm

You're making it harder on yourself.

Use BitmapFactory.decodeFile(String path)
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 6 guests