OpenFlashChart将FLASH导出成图片
解念
2023-12-01
Flash 转换成image
通过javascript 把FLASH 把div 转成Image,这种方法在客户端显示。不能保存到服务器。
< script src="js/jquery-1.2.6.min.js" type="text/javascript" ></ script>
< script type="text/javascript" src="js/swfobject.js" ></ script>
< script type="text/javascript" >
swfobject.embedSWF (
"open-flash-chart.swf" , "my_chart" ,
"550" , "250" ,"9.0.0" , "expressInstall.swf" ,
{ "data-file": "gallery/3d-bar-chart.php"} ) ;
</ script>
// 这里使用jQuery 来操作,不喜欢这个框架的,可以使用Javascript 。查看:http://teethgrinder.co.uk/open-flash-chart-2/save-image-js.php
< script type="text/javascript" >
OFC = {} ;
OFC.jquery ={
name : "jQuery" ,
version: function( src){ return$( '#'+ src)[ 0 ] .get_version() } ,
rasterize: function( src, dst){ $( '#' + dst) .replaceWith( OFC.jquery .image( src)) } ,
image: function( src){ return"<img src='data:image/png;base64," + $( '#'+ src)[ 0 ] .get_img_binary() + "' />" } ,
popup: function( src){
var img_win= window.open( '' , 'Charts: Export as Image' )
with ( img_win.document) {
write ( '<html><head><title>Charts: Export as Image<// title><// head><body>'+ OFC.jquery .image( src) + '< //body>< //html>' )}
// stop the 'loading...' message
img_win.document .close() ;
}
}
// Using an object as namespaces is JS Best Practice. I like the Control.XXX style.
//if (!Control) {var Control = {}}
//if (typeof(Control == "undefined")) {var Control = {}}
if (typeof ( Control== "undefined")) { var Control = { OFC: OFC.jquery}}
// By default, right-clicking on OFC and choosing "save image locally" calls this function.
// You are free to change the code in OFC and call my wrapper (Control.OFC.your_favorite_save_method)
// function save_image() { alert(1); Control.OFC.popup('my_chart') }
function save_image(){ alert ( 1 ); OFC.jquery .popup( 'my_chart') }
function moo(){ alert ( 99 ); } ;
</ script>
<INPUT TYPE =BUTTONOnClick ="OFC.jquery.rasterize('my_chart', 'img_chart_1')"VALUE ="Add image in the table" >
OFC.jquery.rasterize('my_chart', 'img_chart_1')
//
rasterize 是转换成图片
my_chart 、 img_chart_1 为div 的ID my_chart 为显示FLASH 的。。
mg_chart_1 就是把Image 转换成图片显示的ID
OFC.jquery.rasterize('my_chart', 'my_chart'); 这个就在原div 里转换成图片
OFC.jquery.popup('my_chart') 为打开一个新页面。输出一个图片。