markus / KCOM / Events / Export.cs @ d60f94ee
이력 | 보기 | 이력해설 | 다운로드 (6.99 KB)
1 | 787a4489 | KangIngu | 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 | 86bff326 | taeseongkim | public System.Drawing.Image Exporting(Visual visual,double pageWidth,double pageHeight) |
131 | { |
||
132 | BitmapEncoder encoder = new PngBitmapEncoder(); |
||
133 | RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)pageWidth, (int)pageHeight, 96d, 96d, PixelFormats.Default); |
||
134 | |||
135 | DrawingVisual drawingVisual = new DrawingVisual(); |
||
136 | using (DrawingContext drawingContext = drawingVisual.RenderOpen()) |
||
137 | { |
||
138 | VisualBrush visualBrush = new VisualBrush(visual); |
||
139 | drawingContext.DrawRectangle(visualBrush, null, new System.Windows.Rect(new System.Windows.Point(0,0), new System.Windows.Point(pageWidth, pageHeight))); |
||
140 | } |
||
141 | |||
142 | renderBitmap.Render(drawingVisual); |
||
143 | MemoryStream mystream = new MemoryStream(); |
||
144 | encoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
||
145 | encoder.Save(mystream); |
||
146 | |||
147 | System.Drawing.Image myImage; |
||
148 | myImage = System.Drawing.Image.FromStream(mystream); |
||
149 | |||
150 | //using (Graphics gr = Graphics.FromImage(Resultimg)) |
||
151 | //{ |
||
152 | // //Graphics 객체에 Image 를 그릴때 Rectangle x,y 값을 추가 입력 |
||
153 | // gr.DrawImage(myImage, new Rectangle(0,0,img.Width,img.Height)); |
||
154 | //} |
||
155 | |||
156 | //image = RasterImageConverter.ConvertFromImage(Resultimg, ConvertFromImageOptions.None); |
||
157 | |||
158 | return myImage; |
||
159 | } |
||
160 | |||
161 | public System.Drawing.Image Exporting_old(Canvas canvas, System.Drawing.Image img) |
||
162 | 787a4489 | KangIngu | { |
163 | System.Drawing.Image Resultimg = new System.Drawing.Bitmap(img, img.Width, img.Height); |
||
164 | |||
165 | Size size = new Size((int)img.Width, (int)img.Height); |
||
166 | |||
167 | BitmapEncoder encoder = new PngBitmapEncoder(); |
||
168 | RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)canvas.Width, (int)canvas.Height, 96d, 96d, PixelFormats.Default); |
||
169 | |||
170 | renderBitmap.Render(canvas); |
||
171 | MemoryStream mystream = new MemoryStream(); |
||
172 | encoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
||
173 | encoder.Save(mystream); |
||
174 | |||
175 | System.Drawing.Image myImage; |
||
176 | myImage = System.Drawing.Image.FromStream(mystream); |
||
177 | |||
178 | using (Graphics gr = Graphics.FromImage(Resultimg)) |
||
179 | { |
||
180 | e8f03842 | djkim | //Graphics 객체에 Image 를 그릴때 Rectangle x,y 값을 추가 입력 |
181 | 86bff326 | taeseongkim | gr.DrawImage(myImage, new Rectangle(0, 0, img.Width, img.Height)); |
182 | 787a4489 | KangIngu | } |
183 | |||
184 | //image = RasterImageConverter.ConvertFromImage(Resultimg, ConvertFromImageOptions.None); |
||
185 | |||
186 | return Resultimg; |
||
187 | } |
||
188 | } |
||
189 | } |