개정판 77cdac33
벽산 수정 후 백업
Change-Id: I8e3eb48f615478a49efa0ab4014a8ef17d273d0a
KCOM/Events/Export.cs | ||
---|---|---|
158 | 158 |
return myImage; |
159 | 159 |
} |
160 | 160 |
|
161 |
public bool ExportingFile(Visual visual, double pageWidth, double pageHeight, string fileName) |
|
162 |
{ |
|
163 |
bool result = false; |
|
164 |
|
|
165 |
try |
|
166 |
{ |
|
167 |
JpegBitmapEncoder png = new JpegBitmapEncoder(); |
|
168 |
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)pageWidth, (int)pageHeight, 96d, 96d, PixelFormats.Default); |
|
169 |
|
|
170 |
DrawingVisual drawingVisual = new DrawingVisual(); |
|
171 |
DrawingContext drawingContext = drawingVisual.RenderOpen(); |
|
172 |
VisualBrush visualBrush = new VisualBrush(visual); |
|
173 |
drawingContext.DrawRectangle(visualBrush, null, new System.Windows.Rect(new System.Windows.Point(0, 0), new System.Windows.Point(pageWidth, pageHeight))); |
|
174 |
drawingContext.Close(); |
|
175 |
|
|
176 |
renderBitmap.Render(drawingVisual); |
|
177 |
png.Frames.Add(BitmapFrame.Create(renderBitmap)); |
|
178 |
|
|
179 |
using (FileStream fileStream = File.Create(fileName)) |
|
180 |
{ |
|
181 |
png.Save(fileStream); |
|
182 |
|
|
183 |
//encoder = null; |
|
184 |
//renderBitmap.Clear(); |
|
185 |
//drawingVisual = null; |
|
186 |
//drawingContext.Close(); |
|
187 |
//visualBrush = null; |
|
188 |
//fileStream.Close(); |
|
189 |
//fileStream.Dispose(); |
|
190 |
|
|
191 |
result = true; |
|
192 |
} |
|
193 |
} |
|
194 |
catch (Exception ex) |
|
195 |
{ |
|
196 |
throw new Exception("ExportingFile Error ", ex); |
|
197 |
} |
|
198 |
finally |
|
199 |
{ |
|
200 |
GC.Collect(); |
|
201 |
GC.WaitForPendingFinalizers(); |
|
202 |
GC.Collect(); |
|
203 |
} |
|
204 |
|
|
205 |
return result; |
|
206 |
} |
|
207 |
|
|
161 | 208 |
public System.Drawing.Image Exporting_old(Canvas canvas, System.Drawing.Image img) |
162 | 209 |
{ |
163 | 210 |
System.Drawing.Image Resultimg = new System.Drawing.Bitmap(img, img.Width, img.Height); |
내보내기 Unified diff