markus / KCOM / Events / Export.cs.bak @ 65eb8dd6
이력 | 보기 | 이력해설 | 다운로드 (3.19 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 RasterImage Exporting(Canvas canvas) |
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 |
} |
98 |
} |