|
|
|
@ -33,37 +33,6 @@ namespace PEIS.Utils |
|
|
|
|
{ |
|
|
|
|
public static class ReportHelper |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// 逆时针旋转图片的函数 |
|
|
|
|
public static Image RotateImage(Image img) |
|
|
|
|
{ |
|
|
|
|
// 旋转角度为负90度 |
|
|
|
|
float angle = -90f; |
|
|
|
|
|
|
|
|
|
// 计算旋转后的图像的矩形范围 |
|
|
|
|
RectangleF bounds = new RectangleF(0, 0, img.Height, img.Width); |
|
|
|
|
|
|
|
|
|
// 创建旋转后的位图 |
|
|
|
|
Bitmap rotatedImage = new Bitmap((int)bounds.Width, (int)bounds.Height); |
|
|
|
|
rotatedImage.SetResolution(img.HorizontalResolution, img.VerticalResolution); |
|
|
|
|
|
|
|
|
|
using (Graphics g = Graphics.FromImage(rotatedImage)) |
|
|
|
|
{ |
|
|
|
|
// 设置插值模式以改善旋转后图像的质量 |
|
|
|
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic; |
|
|
|
|
// 设置旋转中心点 |
|
|
|
|
g.TranslateTransform(rotatedImage.Width / 2, rotatedImage.Height / 2); |
|
|
|
|
// 旋转角度 |
|
|
|
|
g.RotateTransform(angle); |
|
|
|
|
// 将旋转中心点恢复到原点 |
|
|
|
|
g.TranslateTransform(-img.Width / 2, -img.Height / 2); |
|
|
|
|
// 绘制旋转后的图片 |
|
|
|
|
g.DrawImage(img, new PointF(0, 0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return rotatedImage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// PDF to Image |
|
|
|
|
/// </summary> |
|
|
|
@ -73,11 +42,11 @@ namespace PEIS.Utils |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
// 德宏中医院 ECG 心电保存的结果为图片JPG 不是PDF |
|
|
|
|
using (var ms = new MemoryStream(pdf, 0, pdf.Length)) |
|
|
|
|
{ |
|
|
|
|
return Image.FromStream(ms, true); |
|
|
|
|
} |
|
|
|
|
//// 德宏中医院 ECG 心电保存的结果为图片JPG 不是PDF |
|
|
|
|
//using (var ms = new MemoryStream(pdf, 0, pdf.Length)) |
|
|
|
|
//{ |
|
|
|
|
// return Image.FromStream(ms, true); |
|
|
|
|
//} |
|
|
|
|
using (var memoryStream = new MemoryStream(pdf)) |
|
|
|
|
{ |
|
|
|
|
using (var pdfDocument = PdfiumViewer.PdfDocument.Load(memoryStream)) |
|
|
|
@ -88,7 +57,6 @@ namespace PEIS.Utils |
|
|
|
|
{ |
|
|
|
|
using (var stream = new MemoryStream()) |
|
|
|
|
{ |
|
|
|
|
bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone); |
|
|
|
|
bitmap.Save(stream, ImageFormat.Jpeg); |
|
|
|
|
var img = stream.ToArray(); |
|
|
|
|
|
|
|
|
|