When export image, can i export only the area where strokes exist?
S
Sjwee
started a topic
about 2 years ago
if there's a way, please tell me
Best Answer
O
Olivier @MyScript
said
about 2 years ago
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
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
S
Sjwee
said
about 2 years ago
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.
O
Olivier @MyScript
said
about 2 years ago
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
S
Sjwee
said
about 2 years ago
I'll try this.
Thank you very much.
S
Sjwee
said
about 2 years ago
There's another question,i transformed the position in bounding-box, and it's not match with the image i exported
Is there something i did wrong?
Thanks
O
Olivier @MyScript
said
about 2 years ago
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
S
Sjwee
said
about 2 years ago
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?
Thanks for your patience
O
Olivier @MyScript
said
about 2 years ago
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.
Sjwee
if there's a way, please tell me
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
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstOlivier @MyScript
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
Sjwee
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.
Olivier @MyScript
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
Sjwee
I'll try this.
Thank you very much.
Sjwee
There's another question,i transformed the position in bounding-box, and it's not match with the image i exported
Is there something i did wrong?
Thanks
Olivier @MyScript
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
Sjwee
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?
Thanks for your patience
Olivier @MyScript
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
Sjwee
Thanks