Jump to content

martincg

Members
  • Content Count

    5
  • Joined

  • Last visited

Everything posted by martincg

  1. martincg

    Skia4Delphi

    SkiDraw stops Image1MouseMove from firing. When I use SkiDraw, somehow it stops my image1mousemove being called. The effect that I see with this is that when I try to drag an image it appears to move only when the mouse movement stops. If I add a line in my Image1MouseMove procedure to update a label with the mouse coordinates then the label caption doesn't change while the mouse is moving but updates when the mouse movement stops. This doesn't happen with VCL standard drawing. With that I can drag the drawing around as fast as I can move the mouse. Update; Although it appeared to stop on mousemove being called I found that the image was being redrawn but not repainted. By adding image1.Repaint the speed is back to normal. I don't have an understanding of why using canvas,SkiaSDraw stops the form from repainting.
  2. martincg

    Skia4Delphi

    Oh, thank you vfbb. I should have seen that!. It does exactly what I want. I can do this- ABitMap.SkiaDraw(dodraw2, false); or if I use an anonomous procedure it works like this ABitMap.SkiaDraw(procedure (const ACanvas:ISKCanvas) begin //code end, DoStartClean); //<--second parameter here. BTW, the conversion I have done to Skia so far using SkiaDraw is a lot slower than VCL canvas.draw.... I haven't measured it but as a guess I would think 5 times slower. Is that to be expected?
  3. martincg

    Copy from a LSKSurface to a TSKPaintBox

    I want to draw on a LSKSurface and then update the TSKPaintBox with the result. The problem I have is that the drawing shown in the SKPaintBox does not appear to be antialiased. If I draw straight into the paintbox canvas all is fine, and if I draw in the surface canvas and save a snapshot to a png image then the result is also fine. //=============CanvasA is canvas for a TSKPaintBox =================== procedure TfrmMain.drawTest(canvasA: ISkCanvas; targetRect: TRectF); var paint: ISkPaint; LSurface: ISKSurface; LFont1:ISkFont; LTypeface:ISkTypeface; rot:single; tempimg:ISKImage; RWidth,RHeight:integer; cancan:ISKCanvas; begin RWidth := round(targetRect.Width); RHeight := round(targetRect.Height); canvasA.Scale(1,1); LSurface := TSkSurface.MakeRaster(RWidth, RHeight); Lsurface.Canvas.Scale(1,1); //cancan := canvasA; cancan := LSurface.canvas; cancan.Clear(TAlphaColors.Aqua); // refresh canvas paint := TSKPaint.Create; Paint.SetColorF(TAlphaColorF.Create(TALphaColorRec.Blue)); paint.AntiAlias := true; paint.StrokeWidth := 1;//6; paint.Style := TSkPaintStyle.Stroke; // .fill .strokeandfill cancan.DrawLine(0, 0, 200, 700, paint); cancan.drawcircle(500,500,200,paint); LSurface.MakeImageSnapshot.EncodeToFile('C:\temp\skia1.png');//looks OK - no jaggies tempimg := lsurface.MakeImageSnapshot; if cancan <> canvasA then canvasA.DrawImageRect(tempimg,targetRect,targetRect);// has jaggies end; Can someone explain where I am going wrong?
  4. martincg

    Skia4Delphi

    I want to convert several programs to use Skia for Delphi so that the drawings are antialiased. (Delphi 11.1) The easiest way seems to be to use TBitmap.SkiaDraw, then TImage.Canvas.Copyrect to get the drawing onto the image. How do I do this but keep what was drawn on the image before? Say I have one procedure which draws stgae1. Then later, I want to draw stage2 over stage1. So far I haven't understaood how to 'update' animage. Using a TBitmap and a TImage is good for my requirements because the original programs all drew on bitmaps which were then copied to an image. But if I copy from the stage1 on the image canvas to a bitmap and then use SKiaDraw on the bitmap to draw stage2 then stage1 is lost. Can anyone suggest what should be done?
  5. martincg

    Copy from a LSKSurface to a TSKPaintBox

    The solution is (partly) Keep the original TImage and the TBitmap. Draw on the bitmap using Bitmap.SkiDraw(procedure(Const ACanvas:ISKCanvas) begin //code to draw using Skia draw functions .. end); Then do image.canvas.copyrect(rect(...), bitmap.canvas, rect(..)) This works for me although I have the following gripes and problems. A) The drawing procedure called can be aanonomous as I showed or it can be a procedure but, as far as I have been able to find, I cannot see how to have the procedure as a sub procedure in the same procedure so that the variables are shared. This makes the drawing process extremely awkward especially if I want to do B. B) I want to draw on the image, and then draw over the top of what was first drawn. If anyone can tell me how to do that then please do. All attempts I have made so far have failed. For example, if I copy the image to a bitmap then use SKiaDraw on the bitmap the original image information is wiped. I have no doubt that my ignorance is the main problem so if anyone can point me to a good source of learning and examples for SKI for DElphi that would be great. (Video tutorials arer no help to me.)
×