Author: Christian Lopes
Date: 2011-05-03 13:24:52 -0700 (Tue, 03 May 2011)
New Revision: 24907
Modified:
cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ApplicationMediator.as
Log:
Fixed issue #2500 (Invalid BitmapData Error when generating large PNG images) -
CW will also require at least Flash 10, because bitmap size limitations were
increased in that version.
Modified: cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js
===================================================================
--- cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js
2011-05-03 20:17:37 UTC (rev 24906)
+++ cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js
2011-05-03 20:24:52 UTC (rev 24907)
@@ -1651,11 +1651,11 @@
*/
embedSWF: function () {
//Major version of Flash required
- var requiredMajorVersion = 9;
+ var requiredMajorVersion = 10;
//Minor version of Flash required
var requiredMinorVersion = 0;
//Minor version of Flash required
- var requiredRevision = 24;
+ var requiredRevision = 0;
var containerId = this.containerId;
Modified:
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ApplicationMediator.as
===================================================================
---
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ApplicationMediator.as
2011-05-03 20:17:37 UTC (rev 24906)
+++
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ApplicationMediator.as
2011-05-03 20:24:52 UTC (rev 24907)
@@ -212,14 +212,35 @@
if (type === "png") {
var bounds:Rectangle = graphView.vis.getRealBounds();
+
// At least 1 pixel:
- bounds.width = bounds.width > 0 ? bounds.width : 1;
- bounds.height = bounds.height > 0 ? bounds.height : 1;
+ var w:int = Math.max(bounds.width, 1);
+ var h:int = Math.max(bounds.height, 1);
+ // Maximum pixel count
(http://kb2.adobe.com/cps/496/cpsid_49662.html)
+ var pcount:int = w * h;
+ const MAX_PCOUNT:Number = 0xFFFFFF;
+ const MAX_PSIDE:Number = 8191;
+ var f:Number = 1;
+
+ if (pcount > MAX_PCOUNT)
+ f = f * MAX_PCOUNT/pcount;
+
+ var maxSide:int = Math.max(w, h);
+
+ if (maxSide > MAX_PSIDE)
+ f = f * MAX_PSIDE/maxSide;
+
+ if (f < 1) {
+ w *= f;
+ h *= f;
+ }
+
+ // Draw the image:
var color:uint =
configProxy.config.visualStyle.getValue(VisualProperties.BACKGROUND_COLOR);
-
- var source:BitmapData = new BitmapData(bounds.width,
bounds.height, false, color);
+ var source:BitmapData = new BitmapData(w, h, false, color);
var matrix:Matrix = new Matrix(1, 0, 0, 1, -bounds.x,
-bounds.y);
+ matrix.scale(f, f);
source.draw(graphView.vis, matrix);
var encoder:PNGEncoder = new PNGEncoder();
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.