emf 포맷 사진, 3일 걸렸어요.
2641 단어 emf
public static byte[] createEmfTag(String sRand) throws Exception{
Random random = new Random();//
Vector<EMFTag> emf = new Vector<EMFTag>();
//
RoundRect rr=new RoundRect(new Rectangle(10, 10, 119, 59) ,new Dimension(1,1));
emf.add(rr);
// , 。
// LogFontW font = new LogFontW(-82, 0, 0, 0, 0, false, true, false,0, 3, 2, 1, 0x22, "Times New Roman");
// Panose panose = new Panose();
// ExtLogFontW extFont = new ExtLogFontW(font, "", "", 0, 0, 0, new byte[] {0, 0, 0, 0}, 0, panose);
// ExtCreateFontIndirectW ecfi=new ExtCreateFontIndirectW(1,extFont);
// emf.add(ecfi);
//
SetTextColor st=new SetTextColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
emf.add(st);
//
TextW tw=new TextW(new Point(20, 30),sRand, 0, new Rectangle(1, 1, 11, 5), new int[] { 30, 30, 30, 0, 0 });
emf.add(new ExtTextOutW(new Rectangle(0,0,120,60), 2, 120, 60, tw));
// 10
for (int i = 0; i < 10; i++) {
LineTo lt=new LineTo(new Point(random.nextInt(150),random.nextInt(80)));
emf.add(lt);
}
// 100
for (int i = 0; i < 100; i++) {
emf.add(new SetPixelV(new Point(random.nextInt(120),random.nextInt(60)),getRandColor(160, 200)));
}
emf.add(new EOF());
ByteArrayOutputStream os = new ByteArrayOutputStream();
try{
EMFOutputStream out = new EMFOutputStream(os, new Rectangle(10, 10, 119, 59),
new EMFHandleManager(), "", "", new Dimension(120, 60));
for (int i = 0; i < emf.size(); i++) {
out.writeTag((org.freehep.util.io.Tag)emf.get(i));
}
out.close();
return os.toByteArray();
}catch(Exception ex){
throw ex;
}finally{
if (os != null)
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static Color getRandColor(int lower, int upper) {
Random random = new Random();
if (upper > 255)
upper = 255;
if (upper < 1)
upper = 1;
if (lower < 1)
lower = 1;
if (lower > 255)
lower = 255;
int r = lower + random.nextInt(upper - lower);
int g = lower + random.nextInt(upper - lower);
int b = lower + random.nextInt(upper - lower);
return new Color(r, g, b);
}