BezierPath to image

  1. 5 years ago

    Joel_Eisenstat

    11 Aug 2018 User since 2016

    Hi ,
    I am using the BezierPath class to create an annotation superimposed on an image. It works quite well as View1 is easily placed over an ImageView . The difficulty is converting the path to an image. < func image(): Image Convert the BezierPath to an Image>
    The code used is ; var annImage = View1.path.image(); , where the Console shows <UIImage: 0x6000018ee180> for annimage.
    However ImageView1.image = annimage; draws a blank .
    Also going forward in having the annotation stay with the image I am not sure of the best approach, somehow merge the images
    , record the bezierpath and reproduce it each time, superimpose the images over each other or use a plug in when that is available.
    Any direction is a appreciated.
    Joel

  2. Joel_Eisenstat

    11 Aug 2018 User since 2016

    So far the way forward is to pass the image and the bezierpath separately and then combine them . Note there is a discrepancy between the simulator and CreoPlayer. In the simulator the image and path do NOT align as per the original ( when frame size changes) but DO in CreoPlayer.

  3. andrea

    13 Aug 2018 Administrator User since 2016

    @Joel_Eisenstat
    I've attached a sample project on how to merge the image from an ImageView and the BezierPath drawn in a View. Basically there is a container View1 that contains the ImageView1 (with a custom image) and a View2 where I draw a BezierPath in the draw event (the bezier path is created when you touch and move the touch inside the View2).
    Then the Button1 get the presented content of the View1 with the image() method of the View class (which is the merged content of the subviews: ImageView1+View2) and set that image in the bottom ImageView2.

    The image() method of the View returns an image with the same size of the View.
    The image() method of the BezierPath you are using returns an image of the size of the smallest rectangle that completely encloses all points in the path (and it may have a problem with the origin of the path, I'm still investigating).

  4. Joel_Eisenstat

    13 Aug 2018 User since 2016

    Thanks Andrea for the detailed response. One other question, how does one clear the newly created BezierPath. I tried setting it to null and redrawing but that doesn't seem to work.
    Regards,
    Joel

  5. andrea

    13 Aug 2018 Administrator User since 2016

    The following code works for the previous example:

    View1.View2.path = null;
    View1.View2.refresh();

or Sign Up to reply!