Improved streetrendering with better shadows.
This commit is contained in:
parent
75743caa53
commit
4f3f4cc322
1 changed files with 27 additions and 25 deletions
|
@ -291,12 +291,11 @@ public class OsmandRenderer {
|
||||||
|
|
||||||
// fill area
|
// fill area
|
||||||
Canvas cv = new Canvas(bmp);
|
Canvas cv = new Canvas(bmp);
|
||||||
|
|
||||||
//needed for better street shadows
|
//needed for better street shadows
|
||||||
Bitmap streetbmp = Bitmap.createBitmap(cv.getWidth(), cv.getHeight(), Bitmap.Config.ARGB_8888);
|
Bitmap streetbmp = Bitmap.createBitmap(cv.getWidth(), cv.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
streetcv = new Canvas(streetbmp);
|
streetcv = new Canvas(streetbmp);
|
||||||
|
|
||||||
|
|
||||||
if(renderer != null){
|
if(renderer != null){
|
||||||
int dc = renderer.getDefaultColor(rc.nightMode);
|
int dc = renderer.getDefaultColor(rc.nightMode);
|
||||||
if(dc != 0){
|
if(dc != 0){
|
||||||
|
@ -418,7 +417,10 @@ public class OsmandRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyListeners(notifyList);
|
notifyListeners(notifyList);
|
||||||
|
|
||||||
|
//Draw streets here
|
||||||
|
drawStreetsWithShadow(cv, streetbmp);
|
||||||
|
|
||||||
drawTextOverCanvas(rc, cv, useEnglishNames);
|
drawTextOverCanvas(rc, cv, useEnglishNames);
|
||||||
long time = System.currentTimeMillis() - now;
|
long time = System.currentTimeMillis() - now;
|
||||||
rc.renderingDebugInfo = String.format("Rendering done in %s (%s text) ms\n" +
|
rc.renderingDebugInfo = String.format("Rendering done in %s (%s text) ms\n" +
|
||||||
|
@ -430,6 +432,18 @@ public class OsmandRenderer {
|
||||||
|
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw nice shadow under all streets
|
||||||
|
//but also other linear objects which is not very good
|
||||||
|
|
||||||
|
private void drawStreetsWithShadow(Canvas cv, Bitmap streetbmp){
|
||||||
|
Paint shadowpaint = new Paint();
|
||||||
|
shadowpaint.setColor(Color.BLACK);
|
||||||
|
shadowpaint.setMaskFilter(new BlurMaskFilter(1, BlurMaskFilter.Blur.SOLID));
|
||||||
|
Bitmap shadowImage = streetbmp.extractAlpha();
|
||||||
|
cv.drawBitmap(shadowImage, 0, 0, shadowpaint);// <----
|
||||||
|
cv.drawBitmap(streetbmp, 0, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw nice shadow for all streets
|
// Draw nice shadow for all streets
|
||||||
private void drawStreetsShadow(Canvas cv, Bitmap streetbmp){
|
private void drawStreetsShadow(Canvas cv, Bitmap streetbmp){
|
||||||
|
@ -913,16 +927,10 @@ public class OsmandRenderer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void drawStreet(Canvas canvas, Path path, float order){
|
|
||||||
if((order < 58) && (order > 46)) {
|
|
||||||
streetcv.drawPath(path, paint);
|
private void drawPolyline(BinaryMapDataObject obj, BaseOsmandRender render, Canvas canvas, RenderingContext rc, TagValuePair pair, int layer) {
|
||||||
}
|
|
||||||
else canvas.drawPath(path, paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void drawPolyline(BinaryMapDataObject obj, BaseOsmandRender render, Canvas canvas, RenderingContext rc, TagValuePair pair, int layer, float order) {
|
|
||||||
if(render == null || pair == null){
|
if(render == null || pair == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -986,22 +994,20 @@ public class OsmandRenderer {
|
||||||
}
|
}
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
rc.main.updatePaint(paint);
|
rc.main.updatePaint(paint);
|
||||||
|
//changed canvas to the global one for streets
|
||||||
drawStreet(canvas, path, order);
|
streetcv.drawPath(path, paint);
|
||||||
|
|
||||||
if (rc.second.strokeWidth != 0) {
|
if (rc.second.strokeWidth != 0) {
|
||||||
rc.second.updatePaint(paint);
|
rc.second.updatePaint(paint);
|
||||||
drawStreet(canvas, path, order);
|
streetcv.drawPath(path, paint);
|
||||||
|
|
||||||
if (rc.third.strokeWidth != 0) {
|
if (rc.third.strokeWidth != 0) {
|
||||||
rc.third.updatePaint(paint);
|
rc.third.updatePaint(paint);
|
||||||
drawStreet(canvas, path, order);
|
streetcv.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rc.adds != null) {
|
if (rc.adds != null) {
|
||||||
for (int i = 0; i < rc.adds.length; i++) {
|
for (int i = 0; i < rc.adds.length; i++) {
|
||||||
rc.adds[i].updatePaint(paint);
|
rc.adds[i].updatePaint(paint);
|
||||||
drawStreet(canvas, path, order);
|
streetcv.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (obj.getName() != null && obj.getName().length() > 0) {
|
if (obj.getName() != null && obj.getName().length() > 0) {
|
||||||
|
@ -1068,10 +1074,6 @@ public class OsmandRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static RenderingPaintProperties[] oneWay = null;
|
private static RenderingPaintProperties[] oneWay = null;
|
||||||
public static RenderingPaintProperties[] getOneWayProperties(){
|
public static RenderingPaintProperties[] getOneWayProperties(){
|
||||||
if(oneWay == null){
|
if(oneWay == null){
|
||||||
|
|
Loading…
Reference in a new issue