mapsforge / vtm

OpenGL vector map library - running on Android, iOS, Desktop and browser.
GNU Lesser General Public License v3.0
268 stars 89 forks source link

CanvasAdapter.decodeSvgBitmap(Inputstream inputstream) ignores the SVG specific Width and Height #73

Closed Longri closed 8 years ago

Longri commented 8 years ago

The scale of SVG's is not only dependent on CanvasAdapter.dpi but also from the aspect ratio!

A square is always the same size no matter what size is specified in the SVG file!

Most SVG's, in the theme have a size of 580x580. With a CanvasAdapter.dpi = 240, the bitmap size will always 30x30, even the size is set to 100x100 or 58x58 in SVG!

EXEL Example: image

72

devemux86 commented 8 years ago

The default 400px is the product of 20x20px symbol size at base dpi. Which for symbols in VTM is 160dpi (and not CanvasAdapter's 240dpi).

The existed calculation has been tested thoroughly in Mapsforge, without problems for aspect ratio or anything else. And that's why it includes the icon surface pixels and not separately the sides.

So can you explain what's the issue here?

BTW have you checked PR #72 in various dpi? The arbitrary value of 13 produces either very large or very small icons.

Longri commented 8 years ago

The existed calculation has been tested thoroughly in Mapsforge, without problems for aspect ratio or anything else. And that's why it includes the icon surface pixels and not separately the sides.

Then I thing I must create a ISSUE on Mapsforge then this calculation produce same size for different squares

So can you explain what's the issue here?

See Table! Different SVG-size produce the same result for Bitmap-size!

The arbitrary value of 13 produces very small icons.

Play with this factor so you have a good size!

Longri commented 8 years ago

Oh you change to

either very large or very small icons.

So I think we must bring all SVG's to the same size (Maybe 580x580)

devemux86 commented 8 years ago

Then I thing I must create a ISSUE an Mapsforge

Yes that should be done, in case of error as the calculation is common.

this calculation produce same size for different squares

Please provide some examples to test, simple spreadsheet numbers are not visual results.

See Table! Different SVG-size produce the same result for Bitmap-size!

As different you mean the SVG canvas size, like the 580x580? They supposed to produce the same result, as we want to have 20x20px symbols at base dpi.

Play with this factor so you have a good size!

Sorry but we don't mean to use arbitrary numbers as factors for calculating a value. The preferred way is always a complete algorithm with understandable and reproducible results.

The existing is like that and can be modified if not working properly, but without fixed values. Also we could make default size not final, for users to modify it as they wish.

Longri commented 8 years ago

Or better, all SVG's have 30x30 and we don't need a factor!

Longri commented 8 years ago

Mappe1.zip

The Excel sheet!

devemux86 commented 8 years ago

Thanks, I checked the spreadsheet. We need to clarify that the svg virtual canvas size (e.g. as seen in Inkscape) has nothing to do with the actual symbol size which we want to achieve on the map view. So both a 580x580 and a 58x58 svg are supposed to be rendered with the same 20x20px base size, keeping the aspect ratio. That was the whole purpose from the beginning.

Do you want to make the DEFAULT_SIZE as public and not final for convenience?

Longri commented 8 years ago

No! I thing the better way is to have the same SVG-size! So maybe the Themer have a little impact on the size! Just as they have it in .png ! A bigger *.png is indeed drawn even bigger, right?

I will look into the SVG collection and maybe bring all to the same size! (30x30)?

devemux86 commented 8 years ago

Sorry I don't understand what you mean or need to do.

SVG files are not supposed to be modified for size, that's a work for the client renderer.

Please explain in detail what is the issue here. The default size? That can be fixed by letting users change DEFAULT_SIZE.

Also note that in Mapsforge we have extra symbol tags like width, height, percent to provide additional size adjustments per symbol.

devemux86 commented 8 years ago

@Longri a friendly reminder, please don't start making changes in the library without first discussing the purpose or the need of them.

That would save you and all valuable time, a discussion must always be preceded for better understanding.

Longri commented 8 years ago

This scaling strategy can only use for the map. I cannot use for a normal SVG.

I have an SVG, which I want to present, but no matter what I specify a size, the result is always the same small bitmap!

bildschirmfoto 2016-07-18 um 15 05 07

               ^^^^

At the moment they don't need any calculation of size because the result is always the same!

                float scaleFactor = CanvasAdapter.dpi / 160;
                double scale = scaleFactor / Math.sqrt((picture.getHeight() * picture.getWidth()) / DEFAULT_SIZE);

                float bitmapWidth = (float) (picture.getWidth() * scale);
                float bitmapHeight = (float) (picture.getHeight() * scale);
devemux86 commented 8 years ago

This scaling strategy can only use for the map. I cannot use for a normal SVG.

How is this related to the map library? :smile: External use of SVG libraries can be done via their own API, using probably the existing size calculation.

And it's important what dpi the device put on CanvasAdapter and which DEFAULT_SIZE you use.

Longri commented 8 years ago

So I must write all SVG stuff new so I don't need the VTM!

devemux86 commented 8 years ago

We don't understand each other. :smile:

Do VTM or Mapsforge have any issues with SVG rendering in the map?

Longri commented 8 years ago

I Understand this!

But wenn I will use SVG for normal, I must write all CanvasAdapter, Bitmap, SvgBitmap..... new! To Work with usage of Width and Height from SVG!

devemux86 commented 8 years ago

You want to render SVG in a platform and do that via a map library (VMT) instead of using directly the SVG library?

Longri commented 8 years ago

I want use both Map and SVG

devemux86 commented 8 years ago

Let's leave the map for the moment, that either works or not.

To render externally SVG in a platform is as easy as using the code inside each static XSvgBitmap.getResourceBitmap method which returns a native platform bitmap, i.e. Android Bitmap, Java BufferedImage, etc. And that could probably need modifications if used for other purposes, but it's still one method to handle locally.

Longri commented 8 years ago

Ok, ignore this PR! I will rename the Issue to “CanvasAdapter.decodeSvgBitmap(Inputstream inputstream) ignores the SVG specific Width and Height” And maybe it will fix later!

I will override the CanvasAdapter for myself! Too bad!

devemux86 commented 8 years ago

Still don't understand what the actual problem is.

Is VTM (and Mapsforge) map works correctly with SVG rendering, Yes or No? That is important for the repository.

Using externally a map library method in your own unspecified and unsupported code, needs to first understand the algorithms. i.e. change of symbol size is done simply by setting different value to DEFAULT_SIZE.

devemux86 commented 8 years ago

Closing also the issue.

Please discuss in the forum first, explaining with Map screenshots the problem to understand what can be done, if needed.

devemux86 commented 8 years ago

@Longri see also #74.