Added image conversion parts from commonwin32.

This commit is contained in:
soukoku
2015-02-18 20:02:39 -05:00
parent bcb1ec2382
commit b27a9ba4cc
18 changed files with 552 additions and 38 deletions

View File

@@ -1,8 +1,14 @@
using NTwain.Data;
using NTwain.Internals;
using NTwain.Interop;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace NTwain
{
@@ -131,5 +137,29 @@ namespace NTwain
}
return Enumerable.Empty<TWInfo>();
}
/// <summary>
/// Gets the bitmap from the <see cref="NativeData"/> if it's an image.
/// </summary>
/// <returns></returns>
public Bitmap GetNativeBitmap()
{
Bitmap image = null;
if (NativeData != IntPtr.Zero)
{
if (PlatformInfo.Current.IsWindows)
{
image = ImageTools.ReadBitmapImage(NativeData);
}
else if (PlatformInfo.Current.IsLinux)
{
image = ImageTools.ReadTiffImage(NativeData);
}
}
return image;
}
}
}