⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dc.java

📁 wmftosvg图片转换源代码。使用前需要下载相关lib先。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                 break;
           //注意,这里的windowInt代表是要调用
           //元记录的序列号码.
              record = ht.selectObject(windowInt);
            // record=(MetaRecord) ls.get(windowInt);
      /*            switch(windowInt){
                   case 0x2fa:
                	  record=(MetaRecord) ls1.get(i-1);
                	  break;
                   case  0x2fc:
                	   record=(MetaRecord) ls2.get(j-1);
                
                   case 0x2fb:
                	   record=(MetaRecord) ls3.get(k-1);
                }*/
                 readrecord(record, true);
                 break;

           case 0x1f0:
            	// System.out.println("0x1f0");
                  windowInt = readInt(parmStream);
                  ls.remove(windowInt);
                 break;

            case 0x325: //polyline
          //   	System.out.println("/polyline");
           
                 numPoints = readInt(parmStream);
                 tempBuffer = "   <polyline verts = \"";
                 tempBuffer = "   <path  d = \"M";
// read 1st point as move to segment
                    x = readInt(parmStream);
                    y = readInt(parmStream);
                    x = mapX(x);
                    y = mapY(y);
                    tempBuffer = tempBuffer + " " + x + "," + y ;                  

                 for (int i = 0; i < numPoints -1; i++){
                    x = readInt(parmStream);
                    y = readInt(parmStream);
                    x = mapX(x);
                    y = mapY(y);
                    tempBuffer = tempBuffer + "L" + x + "," + y ;                  

                 }

                   svgGraphic = svgGraphic + tempBuffer + "\"/> \n";
                 break;  


            case 0x324: //polygon多边型
           // 	System.out.println("polygon");
                 poly = new Polygon();
                 numPoints = readInt(parmStream);

                tempBuffer = "   <polyline verts = \"";
                

                oldx = readInt(parmStream);
                oldy = readInt(parmStream);

                 oldx = mapX(oldx);
                 oldy = mapY(oldy);
                 tempBuffer = "   <path  d = \"M";
                 tempBuffer = tempBuffer + " " + oldx + "," + oldy ;                    

                 for (int i = 0; i < numPoints-1; i++){
                    x = readInt(parmStream);
                    y = readInt(parmStream);
                    x = mapX(x);
                    y = mapY(y);
                    tempBuffer = tempBuffer + "L" + x + "," + y ; 
                 }
                 
                svgGraphic = svgGraphic + tempBuffer + "\"/> \n";
                break;


            case 0x538: //polypolygon
                //    	System.out.println("polypolygon");
                         int numPolys = readInt(parmStream);

                         ncount = new int[numPolys];
                         for (int j = 0; j < numPolys ; j++){

                          ncount[j] = readInt(parmStream);

                         }
                        

                         for (int j = 0; j < numPolys ; j++){
                        Polygon  poly = new Polygon();


                           numPoints = (short) ncount[j];
                           tempBuffer = "   <polyline verts = \"";
         

                           oldx = readInt(parmStream);
                           oldy = readInt(parmStream);

                           oldx = mapX(oldx);
                           oldy = mapY(oldy);

                         tempBuffer = tempBuffer + " " + oldx + "," + oldy ;                    
                        
                          poly.addPoint( oldx ,oldy );
             
                           for (int i = 0; i < numPoints-1; i++){
                              x = readInt(parmStream);
                              y = readInt(parmStream);
                              x = mapX(x);
                              y = mapY(y);

                              tempBuffer = tempBuffer + " " + x + "," + y ;                    
                              
                           }

                                   
                           svgGraphic = svgGraphic + tempBuffer + "\"/> \n";
                         }

                         break;




         case 0x214: //moveto
           //	System.out.println("moveto");
                 oldy = readInt(parmStream);
                 oldx = readInt(parmStream);
                 oldx = mapX(oldx);
                 oldy = mapY(oldy);
                 svgGraphic = svgGraphic +  "   <path  d = \" M " + oldx + " " + oldy + " \"/> \n";
                 break;  

        case 0x209://set text color
                       // save text color
                       // when writing text, switch to text colors
                       // when done writing, switch back
          	     //   System.out.println("set text color");
                    selColor = readLong(parmStream);
                    cvtTool.setColors(selColor);
                    textColor = cvtTool.getRGBColor( selColor);

                    break;
 

                 case 0x201://set BK color
         //   	System.out.println("set BK color");
                    break;

    
                  case 0xa32: // exttext...
        // 	System.out.println("exttext");
                    if (styleSet){
                         svgGraphic = svgGraphic +"</g> \n";
                    } else{
                       styleSet = true;        
                    }


                    svgGraphic = svgGraphic + "<g style = \"stroke: #" + textColor + "\" > \n";
                    y = readInt(parmStream);
                    x = readInt(parmStream);
  
                    x = mapX(x);
                    y = mapY(y);
                    numChars = readInt(parmStream);
                    wOptions = readInt(parmStream);
                    textBuffer = new byte[numChars];
                    try{
                     parmStream.read(textBuffer);
                    }
                    catch(IOException e){ System.err.println(e);}
                    tempBuffer = new String(textBuffer,0); 
                    svgGraphic = svgGraphic + "   <text x = " + "\"" + x + "\"" + " y = " + "\"" + y + "\" >" + tempBuffer + "</text>\n";

                    svgGraphic = svgGraphic +"</g> \n";

                    svgGraphic = svgGraphic + "<g style = \"stroke: #" + penColor + "\" > \n";
                    break;

            case 0xF43: //stretch DIB
          //	System.out.println("stretch DIB");
                    svgGraphic = svgGraphic + "  <desc> DIB - Device independent Bitmap - will convert to JPEG in next release </desc> \n";
                    break;



            case 0x20B: //set_window_org
          // 	System.out.println("set_window_org");
                    logOrgY = readInt(parmStream);
                 //   System.out.println("logOrgY=      " +logOrgY);
                    logOrgX = readInt(parmStream);
                    break;


            case 0x20C: //set_window_ext
        	//System.out.println("set_window_ext");
                    logExtY = readInt(parmStream);
                //    System.out.println("logExtY=      " +logExtY);
                    logExtX = readInt(parmStream);
                       break;
            case   0x1E:
           // 	System.out.println("savedc");
            	svgGraphic = svgGraphic +"\n";
            	break;
            case   0x127:
            	//System.out.println("restoredc");
                break;
            default: //  System.out.println("没有算法的函数类型"+   mRecord.getFunction());
          } // end switch
       
          try{
                       parmStream.close();
                    }
          catch(IOException e){ System.err.println(e);}
        
}

   







   public short mapX(short x){
       d_x = (float)devExtX/logExtX;
       x = (short)(x - logOrgX);
       x = (short) (x*d_x);
       return (x);
   }
   public short mapY(short y){
       d_y = (float)devExtY/logExtY;
       y = (short)(y - logOrgY);
       y = (short) (y*d_y);
       return (y);
   }


   public int flipLong(byte[] byteFlip){
         DataInputStream dl;
         ByteArrayInputStream  b_in;
         byte[] bytebuffer;
         bytebuffer = new byte[4];
         bytebuffer[0] = byteFlip[3];
         bytebuffer[1] = byteFlip[2];  
         bytebuffer[2] = byteFlip[1];  
         bytebuffer[3] = byteFlip[0];  

         b_in = new ByteArrayInputStream(bytebuffer);
         dl = new DataInputStream(b_in);
         try{
           return dl.readInt();
         }
          catch(IOException e){System.err.println(e);}
            return 0;

  }


   public int readLong( DataInputStream d){
       byte[] longBuf =new byte[4];

        try{
            d.read(longBuf);
//            d.readFully(longBuf);
            return flipLong(longBuf);
         }  catch(IOException e){
            System.err.println(e);
            return 99;
         }

   }

   public short readInt( DataInputStream d){
        byte[] intBuf =new byte[2];

        try{
            d.read(intBuf);
//            d.readFully(intBuf);
            return flipInt(intBuf);
         }  catch(IOException e){
            System.err.println(e);
            return 99;
         }

   }



   public short flipInt( byte[] byteFlip){
         DataInputStream d;
         ByteArrayOutputStream b_out;
         ByteArrayInputStream  b_in;
         byte[] bytebuffer;

         bytebuffer = new byte[2];
         bytebuffer[0] = byteFlip[1];
         bytebuffer[1] = byteFlip[0];  

         b_in = new ByteArrayInputStream(bytebuffer);
         d = new DataInputStream(b_in);
         try{
           return d.readShort();
         }
         catch(IOException e){ System.err.println(e);}
            return 0;
        }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -