Delphi Skia:从ISKSurface复制到TSkPaintBox的抗锯齿问题求助
问题:Skia中从ISkSurface复制到TSkPaintBox时抗锯齿失效
我正在将一个使用TBitmap和TImage的Delphi程序改用Skia,以实现抗锯齿绘图。原程序逻辑是先在TBitmap上完成绘制,再通过image.canvas.copyrect复制到TImage。
现在我尝试用ISKSurface替代TBitmap,TSkPaintBox替代TImage:直接在TSkPaintBox画布上绘制时抗锯齿效果正常,但先在ISKSurface绘制完成后再复制到TSkPaintBox时,结果却没有抗锯齿效果。
测试代码如下:
procedure TfrmMain.drawTest(canvasA: ISkCanvas; targetRect: TRectF); var paint: ISkPaint; LSurface: ISKSurface; LFont1:ISkFont; LTypeface:ISkTypeface; rot:single; tempimg:ISKImage; RWidth,RHeight:integer; begin RWidth := round(targetRect.Right); RHeight := round(targetRect.Height); LSurface := TSkSurface.MakeRaster(RWidth, RHeight);// // Set canvas color LSurface.canvas.drawColor(TAlphaColors.Aqua); LSurface.canvas.Clear(TAlphaColors.Aqua); // refresh canvas paint := TSKPaint.Create; Paint.SetColorF(TAlphaColorF.Create(TALphaColorRec.Blue)); paint.AntiAlias := true; paint.StrokeWidth := 1; paint.Style := TSkPaintStyle.Stroke; // .fill .strokeandfill LSurface.canvas.DrawLine(0, 0, 200, 700, paint); LSurface.canvas.drawcircle(500,500,200,paint); LTypeface := TSkTypeface.MakeFromName('Arial',tskFontStyle.normal); LFont1 := TSkFont.Create(LTypeface, 66, 1); LFont1.Edging := TSkFontEdging.AntiAlias; Paint.Style := TSkPaintStyle.Fill; rot := -90; LSurface.canvas.Rotate(rot); LSurface.canvas.DrawSimpleText('234.4', -500,500,LFont1,paint); LSurface.canvas.Rotate(-rot); LSurface.canvas.DrawSimpleText('789', 500,500,LFont1,paint); tempimg := lsurface.MakeImageSnapshot; //only way I can see to get a copy of //LSurface.canvas to TSKPaintBox.canvas canvasA.DrawImageRect(tempimg,targetRect,targetRect); //result is not antialiased. end;
补充说明:将ISKSurface的快照保存为PNG图片时,图片是带有抗锯齿的,因此推测问题出在从ISKSurface复制到TSkPaintBox的缩放环节。
我想了解问题出在哪里,或是该查阅哪些相关资料。
内容的提问来源于stack exchange,提问作者Martincg
相关产品推荐
相关产品推荐

