Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Dealing with saved images

$
0
0

Hi All, I have encounter an issue with managing images that I can't seem to find an answer for. I am developing for iOS, running 7.1, and am using the latest version of the titanium SDK (3.2.2).

More than a year ago, I created an app that allows you to take a picture, and write a description. I take the info and post it to a database, like this:

Titanium.Media.showCamera({
    success:function(event)
    {
        var image = event.media;
 
 imagedealie.image=image;
 
var imageBlob = imagedealie.toImage();
 var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, myfilename);
 f.write(imageBlob);
 
Ti.App.thefile=f.nativePath;
 
displayimage.url=f.nativePath;
 
displayimage.url=image;
'myfilename' is a generated name that I randomly generate to ensure I can find the picture again.

And yes, I used '.url' because I developed this app some time ago, and that's what exists in iTunes currently.

And then I insert it into the database like this:

db.execute("INSERT INTO mydatabase (description,pic) values(''" + mydescription + "'" + Ti.App.thefile + ")");
Of course 'mydescription' is the description that the user provides.

In the production version, if I call the database, I can display the picture like this:

var dbdata=db.execute ("Select * from my database");
 
while (dbdata.isValidRow()) {
 
          images[c]=dbdata.fieldByName('pic'),
     description[c]=dbdata.fieldByName('description');
 
dbdata.next();
}
And then I can proceed to create a overflow, or manipulate the images, in either:
var view = Titanium.UI.iOS.createCoverFlowView({
        images:images,
        backgroundColor:'#eee',
        top:45
        //height: myheight
    });
Or
var img = Ti.UI.createImageView({
          image:dbdata.fieldByName('pic'),
          left:5,
          height:60,
          width:60
        });
And everything works perfectly.

Now I want to revise the app, and put some new features into it. I fixed what I wanted, updated to remove deprecated terminology and have it working in the simulator. It looks good.

The problem is when I deploy it to my device (my iPhone). I am using the same database structure and name. However, any pictures that I call using either of the methods noted above show up as blank images (i.e., as though the wrong URL is being called). But the description does pull correctly and will display.

So my assumption(?) is that in deploying it to the device, somehow the file path is modified.

A couple of questions I have about that: does anyone know if this is an adhoc behavior? And would the result be different if it was deployed through iTunes?

And if that's not the case, does anyone have any suggestions on how to "fix" the issue so it will call the correct picture? It seems like the filename is correct in the database, but I can't determine how to tell what's in there.

In looking at the method I use to take and store the picture, I suppose its possible that I'm actually storing the blob in the database, rather than the filename (without being able to easily access it, I have to admit I'm not sure). If so, is there a way out?

I don't mind creating a second database for the next release that would fix this problem, so long as there's a way to still recover the pictures in the old database - I'd hate to tell users to start over. :)

I'm open to thoughts, suggestions, or advice...

Thank you!


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>