Recently done GIS system Discovery to load WMF pictures in Flex. I remember Flash's loader can only be png,gis,jpg. WMF format is actually window out, flash incredibly not support I was drunk, no way, only background to format, first WMF is the format of the vector, I first think of SVG. Just Java's Batick package can support WMF
Go to SVG. The code is as follows
1 /**2 * Convert WMF to SVG3 * 4 * @paramsrc5 * @paramdest6 */7 PublicString wmftosvg (InputStream insrc) {8 BooleanCompatible =false;9 //String resultstring= "";Ten Try { One //InputStream in = new FileInputStream (SRC); AWmfparser parser =NewWmfparser (); - FinalSvggdi GDI =NewSvggdi (compatible); - Parser.parse (INSRC, GDI); theOrg.w3c.dom.Document doc =gdi.getdocument (); -StringWriter strwite=NewStringWriter (); - - output (doc, strwite); + returnStrwite.getbuffer (). toString (); - //return resultstring; + //GetBuffer (). toString (); A}Catch(Exception e) { at returne.getmessage (); - } - } - - Private voidOutput (Org.w3c.dom.Document doc, stringwriter out)throwsException { -Transformerfactory factory =transformerfactory.newinstance (); inTransformer Transformer =Factory.newtransformer (); -Transformer.setoutputproperty (Outputkeys.method, "xml"); toTransformer.setoutputproperty (outputkeys.encoding, "UTF-8"); +Transformer.setoutputproperty (outputkeys.indent, "yes"); - Transformer.setoutputproperty (Outputkeys.doctype_public, the"-//w3c//dtd SVG 1.0//en"); * Transformer.setoutputproperty (Outputkeys.doctype_system, $"Http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd");Panax NotoginsengTransformer.transform (NewJavax.xml.transform.dom.DOMSource (DOC),NewStreamresult (out)); - Out.flush (); the out.close (); +}
Flex's SVG package is in fact a lot of places, as3svgrendererlib-master use more, GitHub can search to. I tested the online WMF can be no problem, but the system WMF is a building floor map, exported to some words in the picture will be superimposed into a corner inside, I went to this how to do, and did not find any problems in the big half day
You can only use the PNG,WMF format for a lot of different types? Before Flex loaded TIFF, I found that the TIFF format was too much to forget.
This is the stream output instead of PNG
1Base64encoder encode=NewBase64encoder ();2 byte[] wmf= Houserow.getblob ("WMF"); 3 if(wmf!=NULL&&wmf.length>0)4 {5String contentstring =bytetostring (WMF);6InputStream wmfstream=NewStringBufferInputStream (contentstring);7String svgstr=wmftosvg (wmfstream);8Bytearrayoutputstream strwite=NewBytearrayoutputstream (); 9 converttopng (svgstr,strwite);Ten byte[]lens=Strwite.tobytearray (); OneString wmf_pic= ""; A if(Svgstr! =NULL&&!svgstr.equals ("")) - { -Wmf_pic=Encode.encode (lens); the } -Createkeypairxml (Ke12, "WMF", "Floor plan", Wmf_pic, "" "); - - } + - + A /** at * Convert Svgcode to PNG file, direct output to stream - * - * @paramSvgcode SVG Code - * @paramOutputStream output Stream - * @throwsTranscoderexception Exception - * @throwsIOException IO Exception in */ - Public voidconverttopng (String svgcode, OutputStream outputstream) to throwstranscoderexception, IOException { + Try { - byte[] bytes = Svgcode.getbytes ("Iso-8859-1"); thePngtranscoder T =NewPngtranscoder (); * $Transcoderinput input =NewTranscoderinput (Newbytearrayinputstream (bytes));Panax NotoginsengTranscoderoutput output =NewTranscoderoutput (outputstream); - t.transcode (input, output); the Outputstream.flush (); +}finally { A if(OutputStream! =NULL) { the Try { + outputstream.close (); -}Catch(IOException e) { $ e.printstacktrace (); $ } - } - } the } - Wuyi the Public StaticString bytetostring (byte[] in)throwsexception{ -InputStream is =Bytetoinputstream (in); Wu returninputstreamtostring (IS); - } About Public StaticInputStream Bytetoinputstream (byte[] in)throwsexception{ $ -Bytearrayinputstream is =NewBytearrayinputstream (in); - returnis ; - A } + Public StaticString inputstreamtostring (InputStream in)throwsexception{ theBytearrayoutputstream outstream=NewBytearrayoutputstream (); - byte[] data =New byte[In.available ()]; $ intCount=in.read (data,0, data.length); the if((Count!=-1)) the { theOutstream.write (data, 0, count); the } -data =NULL; inString test =NewString (Outstream.tobytearray (), "Iso-8859-1"); the System.out.println (test); the returntest; About } the Public Static byte[] Stringtobyte (String in)throwsexception{ theInputStream is =Stringtoinputstream (in); the returnInputstreamtobyte (IS); + } - Public StaticInputStream Stringtoinputstream (String in)throwsexception{ theBytearrayinputstream is =NewBytearrayinputstream (In.getbytes ("Iso-8859-1"));Bayi returnis ; the } the Public Static byte[] Inputstreamtobyte (InputStream in)throwsexception{ -Bytearrayoutputstream outstream=NewBytearrayoutputstream (); - byte[] Data=New byte[size]; the intCount =-1; the while(Count = In.read (data,0,size))!=-1) the { theOutstream.write (data, 0, count); - } thedata =NULL; the byte[] tt=Outstream.tobytearray (); theFile file=NewFile ("");94Fileimageoutputstream pic_out=Newfileimageoutputstream (file); theBufferedImage img=NewBufferedImage (105,80, BUFFEREDIMAGE.TYPE_3BYTE_BGR); theImageio.write (img, "JPG", OutStream); the returnOutstream.tobytearray ();98 About}
After that will be a load of TIFF and DWG articles, these formats are often used in GIS systems, although the use of FME to deal with is also good, it is a genuine hundreds of thousands of, or forget.
Flex Load Wmf,svg