![]() If Forms.Count = 0 Then New_c.CleanupRichClientDllĮxpSrf.CropSurface(m_X1, m_Y1, m_X2 - m_X1, m_Y2 - m_Y1).WriteContentToPngFile App.Path & "\Export. Set ExpSrf = Cairo.CreateSurface(mo_Srf.Width, mo_Srf.Height)Ĭc.RenderSurfaceContent. RenderSurfaceContent "main", 0, 0, Me.ScaleWidth, Me.ScaleHeight With Cairo.CreateSurface(Me.ScaleWidth, Me.ScaleHeight).CreateContext Rectangle 0, 0, Me.ScaleWidth, Me.ScaleHeight RenderSurfaceContent "main", 0, 0, Me.ScaleWidth, Me.ScaleHeight,, , True For example, it doesn't handle things like automatically resizing the selection rectangle when you resize the form, but it should be OK for demonstrating the basic process.Ĭ "main", App.Path & "\1.png" Mo_Srf.CropSurface(m_X1, m_Y1, m_X2 - m_X1, m_Y2 - m_Y1).WriteContentToJpgFile App.Path & "\crop.jpg"Įnd SubNote that the above example is very basic. ' Crop the image to the user-defined rectangular area and save it (overwriting any existing file of the same name) Fill ' And fill in our path with the selected colour SetSourceColor vbWhite ' Change the fill colour to white FillRule = CAIRO_FILL_RULE_EVEN_ODD ' Set the fill rule to EVEN/ODD so that we are filling between the ellipse and the rectangle ' Note that the RC6 Ellipse method takes the center point of the ellipse for the first 2 parameters, then the width & height of the ellipse for the next 2 parameters. ![]() M_Y2 - m_Y1 ' Draw an ellipse within the bounds of the user-drawn rectangular area. Rectangle 0, 0, Me.ScaleWidth, Me.ScaleHeight ' Create a rectangular path over the whole image - this will be our white fill/erase area The "erase" operation will just be a white fill for this demo ' We have a selection rectangle, so we will draw an ellipse, "erasing" everything outside it. RenderSurfaceContent "main", 0, 0, Me.ScaleWidth, Me.ScaleHeight,, , True ' Render the full original image first (maintaining aspect ratio with the final "True" parameter) Set mo_Srf = Cairo.CreateSurface(Me.ScaleWidth, Me.ScaleHeight) ' Resize our Cairo surface to match the size of the form Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) ' Set end point of user-defined rectangular area/selection Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) ' Set start point of user-defined rectangular area/selection Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ' Load an image into our image list for later drawing in the Redraw methodĬ "main", App.Path & "\orig.jpg" Download 3456 free Loading circle Icons in All design styles. Me.ScaleMode = vbPixels ' When dealing with images, it's easiest to work in pixels. ' Endpoint of user-defined rectangular area for our ellipse ![]() ' Start point of user-defined rectangular area for our ellipse ' Cairo surface of an image and selected ellipse ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |