{ "id": "119746", "key": "TIMOB-15269", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2013-09-10T12:19:37.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:04:06.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "I am trying to capture a image and convert the blob image to byte array.\r\nApplication crashes during this conversion process.\r\nThis piece of code is working fine in SDK 2.1.3.GA.\r\n\r\nTitanium.Media.showCamera({\r\n\t\t\tallowEditing : true,\r\n\t\t\tsuccess : function(e) {\r\n\t\t\t\tvar blob = e.media;\r\n\t\t\t\tvar kilobytes = (e.media.length) / 1024;\r\n\t\t\t\tTi.API.info('[Media Image Size]' + kilobytes + '[KB]');\r\n\t\t\t\tTi.API.info('e :' + JSON.stringify(e));\r\n\t\t\t\tif (e.media.length > 614400) {\r\n\t\t\t\t\tvar imageview = Ti.UI.createImageView({\r\n\t\t\t\t\t\timage : e.media\r\n\t\t\t\t\t});\r\n\t\t\t\t\tif (e.width > e.height) {\r\n\t\t\t\t\t\timageview.width = 800;\r\n\t\t\t\t\t\timageview.height = 800 * (e.height / e.width);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\timageview.height = 800;\r\n\t\t\t\t\t\timageview.width = 800 * (e.width / e.height);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tblob = imageview.toBlob();\r\n\t\t\t\t}\r\n\t\t\t\tvar blobAsKB = (blob.length) / 1024;\r\n\t\t\t\tTi.API.info('[Resized Image]' + blobAsKB + '[KB]');\r\n\t\t\t\tvar fileName = 'Receipt-' + new Date().getTime() + '.JPG';\r\n\t\t\t\tvar newDir = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'Receipts');\r\n\t\t\t\tif (!newDir.exists()) {\r\n\t\t\t\t\tnewDir.createDirectory();\r\n\t\t\t\t}\r\n\t\t\t\tvar writeFile = Titanium.Filesystem.getFile(newDir.nativePath, fileName);\r\n\t\t\t\twriteFile.write(blob);\r\n\t\t\t\twriteFile = Ti.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory + '/Receipts/' + fileName);\r\n\t\t\t\tvar blobObj = writeFile.read();\r\n\t\t\t\tvar encoded = Ti.Utils.base64encode(blobObj);\r\n\t\t\t\tvar str = encoded.toString();\r\n\t\t\t\tvar bytes = [str.length];\r\n\t\t\t\tfor (var i = 0; i < str.length; ++i) {\r\n\t\t\t\t\tbytes.push(str.charCodeAt(i));\r\n\t\t\t\t}\r\n\t\t\t\tConvertedImage = '[' + bytes + ']';\r\n\t\t\t\talert('Image converted to byte array successfully');\r\n\t\t\t},\r\n\t\t\tcancel : function() {\r\n\t\t\t},\r\n\t\t\terror : function(error) {\r\n\t\t\t\tvar alert = Titanium.UI.createAlertDialog({\r\n\t\t\t\t\ttitle : 'Sorry!'\r\n\t\t\t\t});\r\n\t\t\t\tif (error.code == Titanium.Media.NO_CAMERA) {\r\n\t\t\t\t\talert.setMessage('This device does not have a camera.');\r\n\t\t\t\t} else {\r\n\t\t\t\t\talert.setMessage('error: ' + error.code);\r\n\t\t\t\t}\r\n\t\t\t\talert.show();\r\n\t\t\t},\r\n\t\t\tmediaTypes : Ti.Media.MEDIA_TYPE_PHOTO,\r\n\t\t\tsaveToPhotoGallery : true,\r\n\t\t});", "attachment": [ { "id": "42344", "filename": "Allocation Failed.rtf", "author": { "name": "keerthi", "key": "keerthi", "displayName": "Keerthi Santhanam", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-09-10T12:23:13.000+0000", "size": 5647, "mimeType": "text/rtf" } ], "flagged": false, "summary": "Blob image to byte array conversion is not working in SDK 3.1.0.GA", "creator": { "name": "keerthi", "key": "keerthi", "displayName": "Keerthi Santhanam", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "keerthi", "key": "keerthi", "displayName": "Keerthi Santhanam", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Android\r\nTitanium Studio 3.1.0.201304171607\r\nTitanium SDK 3.1.0.GA", "comment": { "comments": [ { "id": "270563", "author": { "name": "keerthi", "key": "keerthi", "displayName": "Keerthi Santhanam", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Application crashes with the error\r\nAllocation Failed - process out of memory.\r\nSee Attachment", "updateAuthor": { "name": "keerthi", "key": "keerthi", "displayName": "Keerthi Santhanam", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-09-10T12:23:13.000+0000", "updated": "2013-09-10T12:23:13.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }