Skip to content

Commit

Permalink
Added new Chrome 6 multipart support and a new Flash image scaling me…
Browse files Browse the repository at this point in the history
…thod.
  • Loading branch information
spocke committed Jun 8, 2010
1 parent df62e6b commit ca1fd3a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog.txt
@@ -1,3 +1,7 @@
Version 1.2.x (2010-xx-xx)
Added new chunking support for Chrome 5 and Firefox 3.6 using the HTML 5 runtime.
Added new multipart upload support for Chrome 6 using the HTML 5 runtime.
Added new image scaling method for the Flash runtime contributed by rcoopman.
Version 1.2.3 (2010-05-27)
Added new drag/drop support for HTML5 running on Chrome beta.
Added new multipart state for the features object. It's now possible to detect multipart support.
Expand Down
44 changes: 43 additions & 1 deletion src/flash/plupload/src/com/plupload/File.as
Expand Up @@ -31,6 +31,10 @@ package com.plupload {
import flash.external.ExternalInterface;
import mx.graphics.codec.JPEGEncoder;
import mx.graphics.codec.PNGEncoder;
import flash.filters.BlurFilter;
import flash.filters.BitmapFilterQuality;
import flash.geom.Point;
import flash.geom.Rectangle;

/**
* Container class for file references, this handles upload logic for individual files.
Expand Down Expand Up @@ -137,16 +141,54 @@ package com.plupload {

// Do we need to scale
if (scale < 1) {
// Set rect and pt for filter area
var rect:Rectangle = new Rectangle(1, 1, loadedBitmapData.width, loadedBitmapData.height);
var pt:Point = new Point(1, 1);

// Set filteramount inversely proportional to resize amount
var filterAmount:Number;

if (scale < .1) {
filterAmount = 5
} else if (scale < .25) {
filterAmount = 4
} else if (scale < .50) {
filterAmount = 3
} else if (scale < .75) {
filterAmount = 2
} else {
filterAmount = 1
}

// Create blurfilter with variable filterAmount of blur
var blurFilter:BlurFilter = new BlurFilter(filterAmount, filterAmount, BitmapFilterQuality.HIGH);

// Create working bitmap to apply filter to. Does not work if applying direct to loadedBitmap for some reason
var workingBitmapData:BitmapData = new BitmapData(loadedBitmapData.width, loadedBitmapData.height);

workingBitmapData.draw(loadedBitmapData, matrix, null, null, null, true);
workingBitmapData.applyFilter(workingBitmapData, rect, pt, blurFilter);

width = Math.round(loadedBitmapData.width * scale);
height = Math.round(loadedBitmapData.height * scale);

// Setup scale matrix
matrix.scale(width / loadedBitmapData.width, height / loadedBitmapData.height);

// Draw workingbitmap into scaled down bitmap
var outputBitmapData:BitmapData = new BitmapData(width, height);
outputBitmapData.draw(workingBitmapData, matrix, null, null, null, true);

/* width = Math.round(loadedBitmapData.width * scale);
height = Math.round(loadedBitmapData.height * scale);
// Setup scale matrix
matrix.scale(width / loadedBitmapData.width, height / loadedBitmapData.height);
// Draw loaded bitmap into scaled down bitmap
var outputBitmapData:BitmapData = new BitmapData(width, height);
outputBitmapData.draw(loadedBitmapData, matrix);

*/
// Encode bitmap as JPEG
if (settings["format"] == "jpg")
file._imageData = new JPEGEncoder(quality).encode(outputBitmapData);
Expand Down

0 comments on commit ca1fd3a

Please sign in to comment.