iink SDK on Device

Answered

When export image, can i export only the area where strokes exist?

if there's a way, please tell me


Best Answer

Dear Sjwee,


currently, our export as image is rather limited as doesn't allow to only export a part of the image.


A solution could consist in exporting as JIIX, so that in your JIIX, you have the position of your ink. The, with a library, you shall then be able to select only part of the image (e.g. the Android Bitmap API: https://developer.android.com/reference/android/graphics/Bitmap)?


Please note that as the JIIX will return with coordinates in mm, you may need to convert these in pixels:

If you want to convert a point from milimeters to pixels, this is done as follows:
Transform tr= editor->getRenderer()->getViewTransform();
Point myPoint(x,y); //coordinates in milimeters
tr.apply(myPoint); //coordinates in pixels


Best regards,


Olivier


Answer

Dear Sjwee,


currently, our export as image is rather limited as doesn't allow to only export a part of the image.


A solution could consist in exporting as JIIX, so that in your JIIX, you have the position of your ink. The, with a library, you shall then be able to select only part of the image (e.g. the Android Bitmap API: https://developer.android.com/reference/android/graphics/Bitmap)?


Please note that as the JIIX will return with coordinates in mm, you may need to convert these in pixels:

If you want to convert a point from milimeters to pixels, this is done as follows:
Transform tr= editor->getRenderer()->getViewTransform();
Point myPoint(x,y); //coordinates in milimeters
tr.apply(myPoint); //coordinates in pixels


Best regards,


Olivier


1 person likes this

Dear Sjwee,


Currently, I am not sure to understand your use-case:

-Do you mean you have a document with strokes and images, then export as an image and would like only the strokes exported?

-Or you have a text part, you export as an image?


Thank you,


Best regards,


Olivier

It's a text part, and i want to export as an image.

There's blank area at the edge of the image. 

I want only the part in the red rect.

image


I'll try this.

Thank you very much.

There's another question,i transformed the position in bounding-box, and it's not match with the image i exported

image

image


Is there something i did wrong?

Thanks



Dear Sjwee,


currently, you did not do anything wrong.


Indeed, after exchanging internally in order to compute the pixel coordinates of the image, you shall convert these to the image resolution, i.e. normally 300 DPI.


The conversion from milimeters to the image resolution shall then be done as follows: pixels=milimeters*300/25.4


Doing tests on my side, it is likely there is a marging that shall be withdrawn to the converted values (likely the layout margins you set: as these are in pixels, you shall convert these in mm using the resolution of your device, then convert to the image resolution -300 DPI-)


This way, you shall be able to have a good approximation of the bouding-box of your text.


Let me know if this helps.


Best regards,


Olivier



Pardon me,i have some trouble understanding english.

Do you mean the dpi of image and device is diffrent, and i need to convert from the result of viewTransform.apply() to image coordinate?

Or i need to add the margins to the bound-box? I created Editor without layout, so there should be no margins. Here is my code. I received touch points from another view and pass points to editor, maybe the points don't fit the coordinate in editor correctly?

image


Thanks for your patience

Dear sjwee,

Indeed, by default bitmaps on Android are 300 DPI. You shall then proceed with the conversion from milimeters to pixels, as explained above.

Also, in case there are margins (e.g. buttons on top of the screen), you may need to substract these to get the exact postion of the text in mms then in pixels.

Best regards,

Olivier

Thanks