public static List <string> SupportedImageFileType(string fileExtension, ImageFileTypes imageFiles)
        {
            List <string> supportedFiles = new List <string>();

            supportedFiles.Add(".jpg");
            supportedFiles.Add(".png");
            return(supportedFiles);
        }
        /// <summary>
        /// バイト配列からWriteableBitmapを生成する
        /// </summary>
        /// <param name="width">幅</param>
        /// <param name="height">高さ</param>
        /// <param name="array">ピクセルデータ</param>
        /// <returns>WriteableBitmapオブジェクト</returns>
        public static WriteableBitmap FromArray(int width, int height, byte[] array, ImageFileTypes type = ImageFileTypes.Normal)
        {
            // 出力用のWriteableBitmapオブジェクトを生成する
            var bitmap = new WriteableBitmap(width, height);
#if WINDOWS_STORE_APPS
            if (type == ImageFileTypes.GifWithStrokes)
            {
                // WriteableBitmapへバイト配列のピクセルデータをコピーする
                using (var pixelStream = bitmap.PixelBuffer.AsStream())
                {
                    pixelStream.Seek(0, SeekOrigin.Begin);

                    var pixelCount = array.Length / 4;
                    for (var i = 0; i < pixelCount; i++)
                    {
                        var index = i * 4;
                        var r = array[index + 0];
                        var g = array[index + 1];
                        var b = array[index + 2];
                        var a = array[index + 3];

                        pixelStream.WriteByte(b);
                        pixelStream.WriteByte(g);
                        pixelStream.WriteByte(r);
                        pixelStream.WriteByte(a);
                    }
                }
            }
            else
            {
                // WriteableBitmapへバイト配列のピクセルデータをコピーする
                using (var pixelStream = bitmap.PixelBuffer.AsStream())
                {
                    pixelStream.Seek(0, SeekOrigin.Begin);
                    pixelStream.Write(array, 0, array.Length);
                }

            }
#elif WINDOWS_PHONE
            int max = width * height;
            for (int i = 0; i < max; i++)
            {
                int index = i * 4;
                int a = array[index + 3];
                int r = array[index + 2];
                int g = array[index + 1];
                int b = array[index + 0];

                bitmap.Pixels[i] = (a << 24 | r << 16 | g << 8 | b);
            }
#endif
            return bitmap;
        }
Exemplo n.º 3
0
 public GMDataExporter( string aDirectory, ImageFileTypes aImageFormat )
     : base(aDirectory)
 {
     m_imageFormat = aImageFormat;
 }
Exemplo n.º 4
0
 public GMDataExporter(string aDirectory, ImageFileTypes aImageFormat) : base(aDirectory)
 {
     m_imageFormat = aImageFormat;
 }
Exemplo n.º 5
0
 public XmlExporter( string aImportDirectory, ImageFileTypes aImageFormat, IEnumerable<ActionLibrary> aLibraries )
     : base(aImportDirectory, aImageFormat)
 {
     m_actionLibs = aLibraries;
 }
 public IRecognitionJob Create(ImageFileTypes fileType, IStoredImageFile file, IConfiguredTesseractEngineFactory engineFactory, IEnumerable <IPreprocessor> preprocessors) =>
 fileType switch
 {
        /// <summary>
        /// IRandomAccessStreamストリームからWriteableBitmapオブジェクトを生成する
        /// </summary>
        /// <param name="stream">IRandomAccessStreamストリーム</param>
        /// <returns>WriteableBitmapオブジェクト</returns>
        public static async Task<WriteableBitmap> FromRandomAccessStreamAsync(IRandomAccessStream stream, ImageFileTypes type = ImageFileTypes.Normal)
        {
            // ストリームからピクセルデータを読み込む
            var decoder = await BitmapDecoder.CreateAsync(stream);
            var transform = new BitmapTransform();
            var pixelData = await decoder.GetPixelDataAsync(decoder.BitmapPixelFormat, decoder.BitmapAlphaMode,
                transform, ExifOrientationMode.RespectExifOrientation, ColorManagementMode.ColorManageToSRgb);
            var pixels = pixelData.DetachPixelData();

            // ピクセルデータからWriteableBitmapオブジェクトを生成する
            return WriteableBitmapLoadExtensions.FromArray((int)decoder.OrientedPixelWidth, (int)decoder.OrientedPixelHeight, pixels, type);
        }
 /// <summary>
 /// IRandomAccessStreamストリームからWriteableBitmapオブジェクトを生成する
 /// </summary>
 /// <param name="stream">IRandomAccessStreamストリーム</param>
 /// <returns>WriteableBitmapオブジェクト</returns>
 public static async Task<WriteableBitmap> FromStreamAsync(IRandomAccessStream stream, ImageFileTypes type = ImageFileTypes.Normal)
 {
     return await FromRandomAccessStreamAsync(stream, type);
 }
 public static async Task<WriteableBitmap> FromFileAsync(StorageFile file, ImageFileTypes type = ImageFileTypes.Normal)
 {
     var bitmap = default(WriteableBitmap);
     using (var strm = await file.OpenStreamForReadAsync())
     {
         bitmap = await WriteableBitmapLoadExtensions.FromStreamAsync(strm, type);
     }
     return bitmap;
 }
        /// <summary>
        /// ストリームからWriteableBitmapオブジェクトを生成する
        /// </summary>
        /// <param name="stream">Streamストリーム</param>
        /// <returns>WriteableBitmapオブジェクト</returns>
        public static async Task<WriteableBitmap> FromStreamAsync(System.IO.Stream stream, ImageFileTypes type = ImageFileTypes.Normal)
        {
            WriteableBitmap retBitmap = null;
#if WINDOWS_STORE_APPS
            // ストリームからbyte配列に読み込む
            stream.Seek(0, SeekOrigin.Begin);
            var bytes = new byte[stream.Length];
            stream.Read(bytes, 0, bytes.Length);

            var buffe = bytes.AsBuffer();

            using (var ras = new InMemoryRandomAccessStream())
            {
                await ras.WriteAsync(buffe);
                ras.Seek(0);
                retBitmap = await FromRandomAccessStreamAsync(ras, type);
            }
#else
            var bitmapSource = new BitmapImage();
            bitmapSource.SetSource(stream);

            retBitmap = new WriteableBitmap(bitmapSource);
#endif
            return retBitmap;
        }