Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #13100 from lightsofapollo/revert-4c652c5
Browse files Browse the repository at this point in the history
Revert "Merge pull request #13097 from dmarcos/bug928614"
  • Loading branch information
lightsofapollo committed Oct 25, 2013
2 parents ad0bf99 + 6080df8 commit 1ec3346
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 41 deletions.
43 changes: 20 additions & 23 deletions apps/camera/js/filmstrip.js
Expand Up @@ -241,28 +241,25 @@ var Filmstrip = (function() {
var previewBlob = blob.slice(metadata.preview.start,
metadata.preview.end,
'image/jpeg');
parseJPEGMetadata(previewBlob, function (thumbnailMetadata) {
metadata.preview.width = thumbnailMetadata.width;
metadata.preview.height = thumbnailMetadata.height;
createThumbnail(
previewBlob,
false,
metadata.rotation,
metadata.mirrored,
function(thumbnail) {
addItem({
isImage: true,
filename: filename,
thumbnail: thumbnail,
blob: blob,
width: metadata.width,
height: metadata.height,
preview: metadata.preview,
rotation: metadata.rotation,
mirrored: metadata.mirrored
});
});
});
createThumbnail(
previewBlob,
false,
metadata.rotation,
metadata.mirrored,
function(thumbnail) {
addItem({
isImage: true,
filename: filename,
thumbnail: thumbnail,
blob: blob,
width: metadata.width,
height: metadata.height,
preview: metadata.preview,
rotation: metadata.rotation,
mirrored: metadata.mirrored
});
}
);
}
}, function logerr(msg) { console.warn(msg); });
}
Expand Down Expand Up @@ -387,7 +384,7 @@ var Filmstrip = (function() {
// Create a thumbnail size canvas, copy the <img> or <video> into it
// cropping the edges as needed to make it fit, and then extract the
// thumbnail image as a blob and pass it to the callback.
function createThumbnail(imageBlob, video, rotation, mirrored, callback)
function createThumbnail(imageBlob, video, rotation, mirrored, callback)
{
offscreenImage.src = URL.createObjectURL(imageBlob);
offscreenImage.onload = function() {
Expand Down
24 changes: 6 additions & 18 deletions shared/js/media/media_frame.js
Expand Up @@ -61,7 +61,6 @@ MediaFrame.prototype.displayImage = function displayImage(blob,
rotation,
mirrored)
{
var previewSizeFillsScreen;
this.clear(); // Reset everything

// Remember what we're displaying
Expand All @@ -78,34 +77,23 @@ MediaFrame.prototype.displayImage = function displayImage(blob,
// Keep track of what kind of content we have
this.displayingImage = true;

function isPreviewBigEnough(preview) {

function bigEnough(preview) {
if (!preview.width || !preview.height)
return false;

// A preview is big enough if at least one dimension is >= the
// screen size in both portait and landscape mode.
var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;
var sw = window.innerWidth;
var sh = window.innerHeight;

return ((preview.width >= screenWidth ||
preview.height >= screenHeight) && // portrait
(preview.width >= screenHeight ||
preview.height >= screenWidth)); // landscape
return ((preview.width >= sw || preview.height >= sh) && // portrait
(preview.width >= sh || preview.height >= sw)); // landscape
}

previewSizeFillsScreen = isPreviewBigEnough(preview);

if (!previewSizeFillsScreen) {
console.error('The thumbnail contained in the jpeg doesn\'t fit' +
'the device screen. The full size image is rendered.' +
'This might cause out of memory errors');
}

// If the preview is at least as big as the screen, display that.
// Otherwise, display the full-size image.
if (preview && (preview.start || preview.filename) &&
previewSizeFillsScreen) {
if (preview && (preview.start || preview.filename) && bigEnough(preview)) {
this.displayingPreview = true;
if (preview.start) {
this.previewblob = blob.slice(preview.start, preview.end, 'image/jpeg');
Expand Down

0 comments on commit 1ec3346

Please sign in to comment.