konradrenner / kolabnotes-android

Note taking app with integrated Kolab sync
GNU Lesser General Public License v3.0
68 stars 17 forks source link

Scaling embedded image #120

Open proninyaroslav opened 8 years ago

proninyaroslav commented 8 years ago

Hello. All images are embedded with the original size (and original DPI) and if the image is too large, it won't fit in DetailFragment and it's necessary to scroll. The same situation with my developed drawing editor - output image has the same resolution as the screen and DetailFragment it even more stretched. Therefore it is necessary to solve a very important problem - scaling image for editor. But there is another problem: since the Kolab Notes service is not limited to smartphones, images, scaled on smartphone, will be too small on the tablet or computer monitor. Do you have any thoughts on this?

screenshot_20160326-121749 screenshot_20160326-121804 screenshot_20160326-121904

konradrenner commented 8 years ago

Ok I see the Problem. Scaling of images without loss of quality is imho just possible with svg.

I think we should go the following way:

Images which are insterted with the file picker should be inserted as they are. If one wants to change its size, he should do it with a third party app.

Maybe it is possible to save handwritten images as svg in the note and scaling is done with the help of the actual density points of the device.

What do you think about this?

proninyaroslav commented 8 years ago

Maybe it is possible to save handwritten images as svg in the note and scaling is done with the help of the actual density points of the device.

The thing is that the activity of drawing editor sends in DialogFragment picture and there it is inserted into the editor. SVG will be scaled in the editor without any manipulation? If so, then it's a good idea, and today I will check it in practice.

proninyaroslav commented 8 years ago

The situation with SVG much more complicated than I thought: 0) Since buildDrawingCache() for canvas returns to bitmap, converting bits to SVG does not give absolutely nothing (besides, SVG librarys does not support it). 1) Adding prefix "data:image/svg" in base64 also has no effect by the reason stated above (at the output usual PNG). 2) The only way out - serializing Path class objects in the SVG (with which editor draws a line), but it requires the creation of a special lib, as I haven't seen such libs in reality.

Therefore consider SVG I would not. It would be possible to develop a format notes (but in this case it's impossible) or attach the image as a file and then scale in the note (but needs to be implemented at the level of Kolab API). I will continue to think over this problem. For now idea is: scale the bitmap before converting into base64.

konradrenner commented 8 years ago

Hmmm, very complicated. But I think scaling for handwritten images would be OK.

I will work on full attachment support for the sync. For local attachment support you can create a new SQL table

konradrenner commented 8 years ago

I already started hacking on the sync api.

@proninyaroslav do you create a sqllite table for attachments in the app code or shall I do that?

proninyaroslav commented 8 years ago

@konradrenner No, I'm now doing exceptionally handwriting editor. Moreover, result image will be embedded in the html

konradrenner commented 8 years ago

Ok, I will continue working on Attachment support

konradrenner commented 8 years ago

@proninyaroslav maybe we should create a setting option, where the user can decide if he wants inline images to be scaled. If scaling is enabled in settings, every image is scaled depending on screen size, if the image does not fit in the screen size (scaling is just done for displaying the note, the scaled image must not be stored with the scaled size). If scaling is disabled, the app behaves like now. What do you think?

proninyaroslav commented 8 years ago

@konradrenner Yes, it's a good idea. I also came up with how to scale image in the drawing editor - give an opportunity user to change size of the canvas on which he will draw.