ฉันกำลังทำงานในโปรเจ็กต์ทดสอบข้ามเพื่อแสดงกราฟคลื่นไฟฟ้าหัวใจแบบเรียลไทม์ มันทำงานได้ดีบน windows และ android ที่ใช้ Xamarin แต่ใน IOS ฉันมีประสิทธิภาพที่ช้าและช้า
ฉันคิดว่าปัญหาเกิดจากการที่ฉันขาดความเชี่ยวชาญใน iOS
ฉันได้ทำการทดสอบสองครั้งแล้วทั้งสองล้มเหลว มีคนมีวิธีแก้ไขให้เร็วขึ้นหรือไม่
ทดสอบ ก
ฉันเรียก Plot แล้วกำหนด UIImage wBitmap เป็น MyView Backgroud ทุก ๆ ‹ 10ms
public void Plot(PointF pPrec, PointF pNext)
{
SizeF bitmapSize = new SizeF(wBitmap.Size);
using (CGBitmapContext context2 = new CGBitmapContext(IntPtr.Zero, (int)bitmapSize.Width, (int)bitmapSize.Height, 8, (int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst))
{
context2.DrawImage(new RectangleF(0, 0, wBitmap.Size.Width, wBitmap.Size.Height), wBitmap.CGImage);
context2.SetLineWidth(1);
context2.AddLineToPoint(pNext.X, pNext.Y);
context2.DrawPath(CGPathDrawingMode.Stroke);
// output the drawing to the view
wBitmap = UIImage.FromImage(context2.ToImage());
}
}
ทดสอบข
ฉันเรียก Plot แล้วกำหนด UIImage wBitmap เป็น MyView Backgroud ทุก ๆ ‹ 10ms
public void Plot2(PointF pPrec, PointF pNext) { UIGraphics.BeginImageContext(wBitmap.Size); context = UIGraphics.GetCurrentContext();
using (context)
{
if (wBitmap != null)
{
context.TranslateCTM(0f, wBitmap.Size.Height);
context.ScaleCTM(1.0f, -1.0f);
context.DrawImage(new RectangleF(0f, 0f, wBitmap.Size.Width, wBitmap.Size.Height), wBitmap.CGImage);
context.ScaleCTM(1.0f, -1.0f);
context.TranslateCTM(0f, -wBitmap.Size.Height);
}
context.SetLineWidth(1);
context.MoveTo(pPrec.X, pPrec.Y);
context.AddLineToPoint(pNext.X, pNext.Y);
context.DrawPath(CGPathDrawingMode.Stroke);
wBitmap = UIGraphics.GetImageFromCurrentImageContext();
}//end using cont
UIGraphics.EndImageContext();
}