c# - Xamarin.Android 中的位图旋转

标签 c# android xamarin xamarin.android zxing

如何在 Xamarin.Android 中将位图旋转 90 度?我正在使用 ZXing.Net.Mobile,C#/.NET 条码扫描库,并且想要垂直打印条码。提前致谢。

最佳答案

获得条形码位图后:

var barcodeWriter = new ZXing.Mobile.BarcodeWriter
{
    Format = ZXing.BarcodeFormat.CODE_128,
    Options = new ZXing.Common.EncodingOptions
    {
        Width = 300,
        Height = 300
    }
};

var barcode = barcodeWriter.Write("ZXing.Net.Mobile");

你可以这样旋转它:

var barcodeRotated = RotateImage(barcode, 90);

这是函数:

private Bitmap RotateImage(Bitmap src, float degrees)
{
    var matrix = new Matrix();

    matrix.PostRotate(degrees);

    return Bitmap.CreateBitmap(src, 0, 0, src.Width, src.Height, matrix, true);
}

结果:

barcode rotated

希望这有帮助!

关于c# - Xamarin.Android 中的位图旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44411013/

相关文章:

android - 错误签名算法不匹配

c# - Monodroid - 处理重用 ListView 行的 subview 上的事件

c# - 自定义 UITableViewCell : First Row Has No Content

c# - 从远程服务器读取 log4net 文件的免费工具

c# - C# 中流畅方法的命名约定?

Android Studio Gradle Sync 因公司代理 : unable to find valid certification path 而失败

c# - 在 Xamarin Forms C# 中发送 HTTP Post 请求

c# - XPath matches() 在 C# 中使用正则表达式

c# - 未设置 ASP.NET Core 2.0 身份验证 Cookie

java - 在下面的代码中是否可以将长数据类型转换为字符串数据类型?