Hello,
I'm struggling with displaying an annotated image in a grid.
So far the best solution I've come up with is using a custom control with the following xBasic:
The above gets me fairly close; however, the resulting image is often displayed with a thick black "border" below (as shown below)
2018-08-15 09_24_26-2018-08-15 09_24_06-SWPPPTrack.png - Greenshot image editor.png
As always, any help would be highly appreciated.
Thanks,
Justin Taylor
I'm struggling with displaying an annotated image in a grid.
So far the best solution I've come up with is using a custom control with the following xBasic:
Code:
function photo_image_render as c (data as p, args as p, PageVars as p) 'do not delete this line with PageVars 'do not delete this line 'Specify the Xbasic that returns the HTML for this control. 'This function must return photo_image_render, which should 'contain the HTML that will be displayed. 'The 'data' argument that is passed in contains the current 'row value for each of the fields in the Grid. For example 'if the Grid displays the customerid, firstname and lastname 'fields, you can reference the values in these fields as 'data.customerid, data.firstname and data.lastname 'JAVASCRIPT: Advanced custom controls might also need to execute 'some javascript. To include javascript with your custom control, set 'the args.javascript property. 'TIP: In the case of Grids based on SQL tables, the current open connection 'can be accessed as: args.rtc.cn (when using this connection, be sure not to close it) ' '------------------------------------------------------------------- on error goto photo_image_xbasicError 'do not delete this line 'Write Xbasic code here that returns the HTML to be displayed by this control if Data.Annotation <> "" dim composite as p = a5_composite_picture_and_ink(Data.Photo_Image,Data.Annotation) dim svg as c = composite.toString() dim scanner as p scanner = stringScanner.Create(svg) if (scanner.replaceSmatchI("style=\"width:*; height:*;","style=\"max-width:100%; height:auto;")) then 'set the annotation dimensions svg = scanner.Text end if dim jpegImage as b = charting::Chart::SvgToJpeg(svg) jpegImage=base64encode(jpegImage) dim vHTML as C = "<img src=\"data:image/jpeg;base64,"+jpegImage+"\" max-width=\"100%\" height=\"auto\" />" else dim jpegImage as C=base64encode(Data.Photo_Image) dim vHTML as C = "<img src=\"data:image/jpeg;base64,"+jpegImage+"\" width=\"*\" height=\"*\" />" end if Photo_Image_render =vHTML end 'do not delete this line photo_image_xbasicError: 'do not delete this line photo_image_render = "Error in custom control xbasic: " + error_text_get() 'do not delete this line end with 'do not delete this line end function 'do not delete this line
The above gets me fairly close; however, the resulting image is often displayed with a thick black "border" below (as shown below)
2018-08-15 09_24_26-2018-08-15 09_24_06-SWPPPTrack.png - Greenshot image editor.png
As always, any help would be highly appreciated.
Thanks,
Justin Taylor