markus / KCOM / Events / Export.cs @ 4913851c
이력 | 보기 | 이력해설 | 다운로드 (5.57 KB)
1 |
using System; |
---|---|
2 |
using System.IO; |
3 |
using System.Collections.Generic; |
4 |
using System.Linq; |
5 |
using System.Text; |
6 |
using System.Threading.Tasks; |
7 |
using System.Drawing; |
8 |
using System.Drawing.Printing; |
9 |
using System.Collections; |
10 |
using System.ComponentModel; |
11 |
using System.Data; |
12 |
using System.Windows.Controls; |
13 |
using System.Windows.Media.Imaging; |
14 |
using System.Windows.Media; |
15 |
using System.Windows.Forms; |
16 |
//강인구 추가 |
17 |
namespace KCOM.Event |
18 |
{ |
19 |
public class Export |
20 |
{ |
21 |
//public RasterImage image |
22 |
//{ |
23 |
// get; |
24 |
// set; |
25 |
//} |
26 |
//public Image image |
27 |
//{ |
28 |
// get; |
29 |
// set; |
30 |
//} |
31 |
|
32 |
#region 원본 |
33 |
//public RasterImage Exporting(Canvas canvas, System.Drawing.Image img) |
34 |
//{ |
35 |
// //canvas.Children.Clear(); |
36 |
|
37 |
// //System.Windows.Controls.Image image_test; |
38 |
// //image_test = new System.Windows.Controls.Image(); |
39 |
|
40 |
// //canvas.Children.Add(image_test); |
41 |
|
42 |
|
43 |
// System.Drawing.Image Resultimg = new Bitmap(img, img.Width, img.Height); |
44 |
|
45 |
|
46 |
// //System.Drawing.Bitmap bmap = new System.Drawing.Bitmap(100, 100); |
47 |
// //System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img); |
48 |
|
49 |
// //Canvas에서 이미지로 변환시 테두리 보임 |
50 |
// //Size size = new Size((int)canvas.Width, (int)canvas.Height); |
51 |
// Size size = new Size((int)img.Width, (int)img.Height); |
52 |
|
53 |
|
54 |
// //System.Drawing.Bitmap bm = new Bitmap(img.Width, img.Height, img.PixelFormat); |
55 |
// //bm.SetResolution(92, 92); |
56 |
|
57 |
|
58 |
|
59 |
// BitmapEncoder encoder = new PngBitmapEncoder(); |
60 |
// RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)canvas.Width, (int)canvas.Height, 96d, 96d, PixelFormats.Default); |
61 |
// //RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Default); |
62 |
|
63 |
// renderBitmap.Render(canvas); |
64 |
// MemoryStream mystream = new MemoryStream(); |
65 |
// encoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
66 |
// encoder.Save(mystream); |
67 |
|
68 |
// System.Drawing.Image myImage; |
69 |
// myImage = System.Drawing.Image.FromStream(mystream); |
70 |
|
71 |
// //System.Drawing.Image img = System.Drawing.Bitmap.FromFile("d:\\hoonslogo.gif"); |
72 |
// //System.Drawing.Image img2 = System.Drawing.Bitmap.FromFile("d:\\btn_individual.gif"); |
73 |
// //g.DrawImage(img, 0, 0); |
74 |
// //g.DrawImage(myImage, 0, 0); |
75 |
|
76 |
// //g.Save(); |
77 |
|
78 |
// using (Graphics gr = Graphics.FromImage(Resultimg)) |
79 |
// { |
80 |
// gr.DrawImage(myImage, new System.Drawing.Point(0, 0)); |
81 |
// //gr.DrawImage(img, new Point(0, 0)); |
82 |
// } |
83 |
|
84 |
|
85 |
// //myImage.Save("C:\\Users\\강인구님\\Desktop\\test1.png"); |
86 |
// //img.Save("C:\\Users\\강인구님\\Desktop\\test2.png"); |
87 |
// //Resultimg.Save("C:\\Users\\강인구님\\Desktop\\test3.png"); |
88 |
|
89 |
// //myImage.Save("C:\\Users\\강인구님\\Desktop\\test3.png"); |
90 |
|
91 |
// image = RasterImageConverter.ConvertFromImage(Resultimg, ConvertFromImageOptions.None); |
92 |
|
93 |
|
94 |
|
95 |
// return image; |
96 |
//} |
97 |
#endregion |
98 |
|
99 |
#region LeadTools빼기 |
100 |
|
101 |
//코멘트가 있는 페이지 |
102 |
//public RasterImage Exporting(Canvas canvas, System.Drawing.Image img) |
103 |
//{ |
104 |
// System.Drawing.Image Resultimg = new System.Drawing.Bitmap(img, img.Width, img.Height); |
105 |
|
106 |
// Size size = new Size((int)img.Width, (int)img.Height); |
107 |
|
108 |
// BitmapEncoder encoder = new PngBitmapEncoder(); |
109 |
// RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)canvas.Width, (int)canvas.Height, 96d, 96d, PixelFormats.Default); |
110 |
|
111 |
// renderBitmap.Render(canvas); |
112 |
// MemoryStream mystream = new MemoryStream(); |
113 |
// encoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
114 |
// encoder.Save(mystream); |
115 |
|
116 |
// System.Drawing.Image myImage; |
117 |
// myImage = System.Drawing.Image.FromStream(mystream); |
118 |
|
119 |
// using (Graphics gr = Graphics.FromImage(Resultimg)) |
120 |
// { |
121 |
// gr.DrawImage(myImage, new System.Drawing.Point(0, 0)); |
122 |
// } |
123 |
// image = RasterImageConverter.ConvertFromImage(Resultimg, ConvertFromImageOptions.None); |
124 |
|
125 |
// return image; |
126 |
//} |
127 |
#endregion |
128 |
|
129 |
//코멘트가 있는 페이지 |
130 |
public System.Drawing.Image Exporting(Canvas canvas, System.Drawing.Image img) |
131 |
{ |
132 |
System.Drawing.Image Resultimg = new System.Drawing.Bitmap(img, img.Width, img.Height); |
133 |
|
134 |
Size size = new Size((int)img.Width, (int)img.Height); |
135 |
|
136 |
BitmapEncoder encoder = new PngBitmapEncoder(); |
137 |
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)canvas.Width, (int)canvas.Height, 96d, 96d, PixelFormats.Default); |
138 |
|
139 |
renderBitmap.Render(canvas); |
140 |
MemoryStream mystream = new MemoryStream(); |
141 |
encoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
142 |
encoder.Save(mystream); |
143 |
|
144 |
System.Drawing.Image myImage; |
145 |
myImage = System.Drawing.Image.FromStream(mystream); |
146 |
|
147 |
using (Graphics gr = Graphics.FromImage(Resultimg)) |
148 |
{ |
149 |
//Graphics 객체에 Image 를 그릴때 Rectangle x,y 값을 추가 입력 |
150 |
gr.DrawImage(myImage, new Rectangle(0,0,img.Width,img.Height)); |
151 |
} |
152 |
|
153 |
//image = RasterImageConverter.ConvertFromImage(Resultimg, ConvertFromImageOptions.None); |
154 |
|
155 |
return Resultimg; |
156 |
} |
157 |
} |
158 |
} |