개정판 c1659a98
issue #0000 Markus.Image.ImageCompare 추가
Change-Id: I82eafc1d99c6765d77546e28ba6151a4766026a5
ImageComparer/Markus.ImageComparer/ImageCompare.cs | ||
---|---|---|
23 | 23 |
|
24 | 24 |
if (rects.Count != 0) |
25 | 25 |
{ |
26 |
using (Graphics g = Graphics.FromImage(Originalbitmap)) |
|
26 |
Bitmap newBitmap = new Bitmap(Originalbitmap.Width, Originalbitmap.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); |
|
27 |
|
|
28 |
using (Graphics g = Graphics.FromImage(newBitmap)) |
|
29 |
{ |
|
30 |
g.DrawImage(Originalbitmap, 0, 0); |
|
31 |
} |
|
32 |
|
|
33 |
using (Graphics g = Graphics.FromImage(newBitmap)) |
|
27 | 34 |
{ |
28 | 35 |
var rect = rects.Select(x => new System.Drawing.Rectangle((int)x.X, (int)x.Y, (int)x.Width, (int)x.Height)).ToList(); |
29 | 36 |
|
... | ... | |
32 | 39 |
|
33 | 40 |
g.Dispose(); |
34 | 41 |
} |
42 |
|
|
43 |
Originalbitmap = newBitmap; |
|
35 | 44 |
} |
36 | 45 |
|
37 | 46 |
return Originalbitmap; |
... | ... | |
209 | 218 |
/// <summary> |
210 | 219 |
/// 메모리 문제 발생 |
211 | 220 |
/// </summary> |
212 |
/// <param name="bitmap"></param>
|
|
221 |
/// <param name="nwdBitmap"></param>
|
|
213 | 222 |
/// <returns></returns> |
214 | 223 |
public System.Windows.Media.Imaging.WriteableBitmap CreateWriteableBitmapFromBitmap(Bitmap bitmap) |
215 | 224 |
{ |
... | ... | |
222 | 231 |
{ |
223 | 232 |
int bytesPerPixel = 4; |
224 | 233 |
|
225 |
result = new System.Windows.Media.Imaging.WriteableBitmap(bitmap.Width, bitmap.Height, |
|
226 |
bitmap.HorizontalResolution ,bitmap.VerticalResolution, |
|
227 |
bitmap.PixelFormat.Convert(), null); |
|
234 |
Bitmap newBitmap = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format32bppArgb); |
|
235 |
using (Graphics g = Graphics.FromImage(newBitmap)) |
|
236 |
{ |
|
237 |
g.DrawImage(bitmap, 0, 0); |
|
238 |
} |
|
239 |
|
|
240 |
result = new System.Windows.Media.Imaging.WriteableBitmap(newBitmap.Width, newBitmap.Height, |
|
241 |
newBitmap.HorizontalResolution , newBitmap.VerticalResolution, |
|
242 |
newBitmap.PixelFormat.Convert(), null); |
|
228 | 243 |
|
229 |
Rectangle colorBitmapRectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
|
|
230 |
System.Windows.Int32Rect colorBitmapInt32Rect = new System.Windows.Int32Rect(0, 0, bitmap.Width, bitmap.Height);
|
|
244 |
Rectangle colorBitmapRectangle = new Rectangle(0, 0, newBitmap.Width, newBitmap.Height);
|
|
245 |
System.Windows.Int32Rect colorBitmapInt32Rect = new System.Windows.Int32Rect(0, 0, newBitmap.Width, newBitmap.Height);
|
|
231 | 246 |
|
232 |
BitmapData data = bitmap.LockBits(colorBitmapRectangle, ImageLockMode.WriteOnly, bitmap.PixelFormat);
|
|
247 |
BitmapData data = newBitmap.LockBits(colorBitmapRectangle, ImageLockMode.WriteOnly, newBitmap.PixelFormat);
|
|
233 | 248 |
|
234 | 249 |
result.WritePixels(colorBitmapInt32Rect, data.Scan0, data.Width * data.Height * bytesPerPixel, data.Stride); |
235 | 250 |
|
236 |
bitmap.UnlockBits(data);
|
|
251 |
newBitmap.UnlockBits(data);
|
|
237 | 252 |
} |
238 | 253 |
catch (Exception ex) |
239 | 254 |
{ |
내보내기 Unified diff