Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14852] Android: Image View does not render all the images captured using device Camera

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2013-10-04T18:04:55.000+0000
Affected Version/sRelease 2.1.4, Release 3.1.0, Release 3.1.1
Fix Version/s2013 Sprint 20, 2013 Sprint 20 API
ComponentsAndroid
Labelsandroid, camera, mobilesdk, titanium
ReporterAshish Nigam
AssigneeSunila
Created2013-08-13T13:56:01.000+0000
Updated2017-03-22T22:54:15.000+0000

Description

Trying to render images on imageView captured using Camera API, But imageView done not render images after 2 or 3 if images are not resized using imageAsResized method. Steps to reproduce: 1: Use the attached app.js or below sample code. 2: Run it using new sample project. 3: Test the application on device (Preferred is Samsung S3 or S2 with android 4.1.2). 4: If images are not resized then after 2 or 3 images, image view won't display them. **sample code**
var mainWin = Ti.UI.createWindow({
	backgroundColor:"#fff"
});
var button = Ti.UI.createButton({
	title : "Take",
	width : "60dp",
	height : "45dp",
	top : "2dp",
	left : "2dp"
});

var button1 = Ti.UI.createButton({
	title : "Add",
	width : "60dp",
	height : "45dp",
	top : "2dp",
	right : "2dp"
});

var scrollView = Ti.UI.createScrollView({
	layout:"horizontal",
	top:"50dp"
})

var successCallBack = function(e) {
		if (e.mediaType != Ti.Media.MEDIA_TYPE_PHOTO) {
			Ti.App.fireEvent('hide_indicator');
			return false;
		}
		
		var image = e.media;//.imageAsResized(120,120); //400 - 17 images added and if only e.media 2 images..
		var filename = (new Date().getTime()) + ".jpg";
		Ti.API.info("JAVA : "+ filename + " " + e.media.getLength());
		
		var newImageView = Ti.UI.createImageView({
			image : image,
			width : "60dp",
			height : "60dp",
			left : "5dp",
			top: "5dp"
		});
		scrollView.add(newImageView);
		var bgImage = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);
		bgImage.write(image);
		//utils.resizeKeepAspectRatioNewWidth(bgImage.getNativePath(), image.width, image.height, Config.imageMaxWidth);
	};


button.addEventListener("click", function(e) {
	Ti.Media.showCamera({
		success : successCallBack,
		mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
	});
});

button1.addEventListener("click", function(e) {
	Ti.Media.openPhotoGallery({
		success : successCallBack,
		mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
	});
});

mainWin.add(scrollView);
mainWin.add(button);
mainWin.add(button1);
mainWin.open();

Attachments

FileDateSize
app.js2013-08-13T13:56:02.000+00001565

Comments

  1. Naga harish M 2013-08-14

    Hi, Even if I use *e.media.imageAsResized* also facing issue. Getting run time issue (Java error). I tried with different modules but no use. Thank you.
  2. Josh Magalich 2013-08-28

    I get the same error after I add 3 or 4 image thumbnails (from the photo gallery) to a view. Is there any work around for this issue? I see the due date got bumped further. Thank you.
  3. Naga harish M 2013-08-28

    Hi [~josh.magalich@crompco.com], I got few suggestion for this issue from Appc saying save the file first and then try to resize or thumbnail from file blob. Even in that case also I am getting java runtime error. Thank you.
  4. Sunila 2013-08-29

    Is this happening for images above a specific size? Also what is the java error you are getting? Is hardware acceleration turned on in the device? There is some limitation in Android showing large image in ImageView with HW acceleration enabled. http://stackoverflow.com/questions/7428996/hw-accelerated-activity-how-to-get-opengl-texture-size-limit
  5. Josh Magalich 2013-08-29

    The runtime error I get is "Uncaught Error: Java exception occurred" Then it tells me my source which is "var blob = e.media.imageAsResized(640, 480);" As for the image size/resolution, if I add 4-5 images of 3264x2448 (2.4 mb each) or like 20 images of of 640x480 (138 Kb each), it throws the error. I do not have hardware acceleration on. I am testing this on my Samsung Galaxy S3. Thanks.
  6. Naga harish M 2013-08-29

    Hi [~sunila], Yes [~josh.magalich@crompco.com],Same result for me also. I also tested in S3 and HTC low/mid end model. I thought it working with small images (Screenshot images). Because I did not tried with 10+ images... May be it seems that also failing after 20 images. Only we are facing this problem in Android. Thank you
  7. Sunila 2013-09-02

    I am able to reproduce the problem, it looks like out of memory error. Since Android allocate fixed size of memory to each application, I don't think there is anything can be done in the code other than scaling the image to smaller size.
  8. Naga harish M 2013-09-03

    Hi [~sunila], Yes It is memory error. But, when I run with Ti SDK 3.0.2 GA version I can upload few more(6-8) images. But, when I run in 3.1.1 it is showing Java error in 3rd images itself. Can you please check same code in 3.0.2. Thank you
  9. Ashish Nigam 2013-09-04

    I can add multiple images if i resize the captured image and use it in imageView. Number of images i can add depends upon resized image size. AvailableMemory API does not seems to be reliable here, so better alternative should be built in SDK to capture such issue and confirm that, by checking availableMemory.
  10. Naga harish M 2013-09-10

    Hi [~sunila], Have you tested same code in Ti SDK 3.0.2 GA version. It works fine with that version. when I run with 3.1.1 only it is showing Java error in two or third image. cc [~anigam]
  11. Ping Wang 2013-10-04

  12. Lee Morris 2017-03-22

    Closing ticket as "Won't Fix".

JSON Source