|
@@ -28,6 +28,7 @@ using System.Collections.ObjectModel;
|
|
|
using System.ComponentModel;
|
|
|
using System.Configuration;
|
|
|
using System.Drawing;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -302,7 +303,7 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
AnnotationListItems[k].UpdateTime = items[j].UpdateTime;
|
|
|
if (items[j].EventType == AnnotArgsType.AnnotFreehand)
|
|
|
{
|
|
|
- WriteableBitmap bitmap = GetAnnotImage(PdfViewer.Document, items[j].PageIndex, items[j].AnnotIndex);
|
|
|
+ BitmapImage bitmap = GetAnnotImage(PdfViewer.Document, items[j].PageIndex, items[j].AnnotIndex);
|
|
|
AnnotationListItems[k].WriteableBitmap = bitmap;
|
|
|
}
|
|
|
AnnotationListItems[k].Content = items[j].Content;
|
|
@@ -1131,7 +1132,7 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
AnnotationHandlerEventArgs args = new AnnotationHandlerEventArgs();
|
|
|
if (item.EventType == AnnotArgsType.AnnotFreehand)
|
|
|
{
|
|
|
- WriteableBitmap bitmap = GetAnnotImage(PdfViewer.Document, item.PageIndex, item.AnnotIndex);
|
|
|
+ BitmapImage bitmap = GetAnnotImage(PdfViewer.Document, item.PageIndex, item.AnnotIndex);
|
|
|
args.WriteableBitmap = bitmap;
|
|
|
}
|
|
|
args.ClientRect = item.ClientRect;
|
|
@@ -1158,7 +1159,7 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
/// <param name="pageIndex"></param>
|
|
|
/// <param name="annotIndex"></param>
|
|
|
/// <returns></returns>
|
|
|
- public WriteableBitmap GetAnnotImage(CPDFDocument doc, int pageIndex, int annotIndex)
|
|
|
+ public BitmapImage GetAnnotImage(CPDFDocument doc, int pageIndex, int annotIndex)
|
|
|
{
|
|
|
if (doc == null)
|
|
|
{
|
|
@@ -1191,15 +1192,51 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
|
|
|
WriteableBitmap wirteBitmap = new WriteableBitmap(drawWidth, drawHeight, 96, 96, PixelFormats.Bgra32, null);
|
|
|
wirteBitmap.WritePixels(new Int32Rect(0, 0, drawWidth, drawHeight), bitmapArray, wirteBitmap.BackBufferStride, 0);
|
|
|
+ BitmapImage bitmapImage = ConvertWriteableBitmapToBitmapImage(wirteBitmap, docPage.Rotation);
|
|
|
|
|
|
cPDFInk.SetRect(rawRect);
|
|
|
- return wirteBitmap;
|
|
|
+ return bitmapImage;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public BitmapImage ConvertWriteableBitmapToBitmapImage(WriteableBitmap wbm, int rotation)
|
|
|
+ {
|
|
|
+ BitmapImage bmImage = new BitmapImage();
|
|
|
+ using (MemoryStream stream = new MemoryStream())
|
|
|
+ {
|
|
|
+ PngBitmapEncoder encoder = new PngBitmapEncoder();
|
|
|
+ encoder.Frames.Add(BitmapFrame.Create(wbm));
|
|
|
+ encoder.Save(stream);
|
|
|
+ bmImage.BeginInit();
|
|
|
+ bmImage.CacheOption = BitmapCacheOption.OnLoad;
|
|
|
+ bmImage.StreamSource = stream;
|
|
|
+ switch (rotation)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ bmImage.Rotation = Rotation.Rotate0;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ bmImage.Rotation = Rotation.Rotate90;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ bmImage.Rotation = Rotation.Rotate180;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ bmImage.Rotation = Rotation.Rotate270;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ bmImage.EndInit();
|
|
|
+ bmImage.Freeze();
|
|
|
+ }
|
|
|
+ return bmImage;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// listbox的itemsource发生变化时
|
|
|
/// </summary>
|