How to draw image from some dir?

All your problems with Audio, Video and Images.

How to draw image from some dir?

Postby odlbo » Tue Dec 01, 2009 8:59 am

Hi everybody!
In my project I have dir 'data' with images. How I can draw images from this dir? I tried to use method decodeFile of class BitmapFactory:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. ...
  3.  
  4. String path_to_file = "data/image.jpeg";
  5.  
  6. BitmapFactory.decodeFile(path_to_file);
  7.  
  8. ...
  9.  
  10.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

but without any success. I think a have mistake in relative file path of image. Can anybody say how to draw this image?

Project tree:
Code: Select all
./ProjectDir
    ./res
    ...
    ./src
    ...
    ./data
        ./image.jpeg


I checked documentation but did not find solution =(
odlbo
Freshman
Freshman
 
Posts: 6
Joined: Tue Dec 01, 2009 8:21 am

Top

Postby padde » Tue Dec 01, 2009 9:08 am

You cant just create resource subfolders at your wish.. it bothers me too any now and then..
but you will have to life with that.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby odlbo » Tue Dec 01, 2009 9:26 am

padde wrote:You cant just create resource subfolders at your wish..


It is not useful for me, because I want to add and draw files in this folder, without recompiling my code.
odlbo
Freshman
Freshman
 
Posts: 6
Joined: Tue Dec 01, 2009 8:21 am

Postby padde » Tue Dec 01, 2009 10:07 am

Well.. sorry for being unuseful.. but thats how it is. You can create folders like you want..
but you cant access files in there. Put the images in the raw folder or in the drawable folder.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby odlbo » Tue Dec 01, 2009 10:32 am

padde wrote:Well.. sorry for being unuseful.. but thats how it is. You can create folders like you want..
but you cant access files in there. Put the images in the raw folder or in the drawable folder.


My mistake, sorry =\
As I understand, I can get access to files in recourse folder only. Is it right?
odlbo
Freshman
Freshman
 
Posts: 6
Joined: Tue Dec 01, 2009 8:21 am

Postby padde » Tue Dec 01, 2009 10:37 am

Yes thats right.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Postby odlbo » Tue Dec 01, 2009 11:01 am

padde wrote:Yes thats right.


Ok. But I know only 1 way to get bitmap from source folder:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.my_image);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

It works.. but if I add new file in this folder, I'll need to recompile code, to draw new image. How can I draw new images without recompiling?
odlbo
Freshman
Freshman
 
Posts: 6
Joined: Tue Dec 01, 2009 8:21 am

Postby padde » Tue Dec 01, 2009 11:17 am

If you create new images while the app is running in one way or the other.. store them in you app directory
by not assigning a path or store the images on the sdcard.
You can later access those files via normal java file access methods.
There is a tutorial floating around in this forum covering the basics of file accessing.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby odlbo » Tue Dec 01, 2009 12:09 pm

Thanks, I'll try to implement all cases :)
odlbo
Freshman
Freshman
 
Posts: 6
Joined: Tue Dec 01, 2009 8:21 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 20 guests