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