備忘録
またまた、調べるの大変なので備忘録
画像を切り抜いたのはいいけど回転させたくなったので検索。
コードがこちら
public async static Task<SoftwareBitmap> SoftwareBitmapRotate(SoftwareBitmap softwarebitmap, uint width, uint height, BitmapRotation Rotation)
{
using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
{
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream);
encoder.SetSoftwareBitmap(softwarebitmap);
encoder.BitmapTransform.Rotation = Rotation;
await encoder.FlushAsync();
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);
return await decoder.GetSoftwareBitmapAsync(softwarebitmap.BitmapPixelFormat, BitmapAlphaMode.Premultiplied);
}
}
問題と対策
MediaCaputureの画像をそのまま回転させていたんですが、処理が重すぎてバーコード読込の間隔が遅すぎて使い物にならなくなりました。
そこで、先に画像を切り抜いてから回転させると気にならないくらいまで改善されました。
(速度は計測していません)
先に切り抜くのもだいぶ苦戦しましたが・・・デバイスの向きで画像の縦横変わるのつらい・・・
まだまだ読み取り精度がいまいち・・・
参考サイト

Create, edit, and save bitmap images - UWP applications
This article explains how to load and save image files using BitmapDecoder and BitmapEncoder and how to use the Software...
コメント