- Timestamp:
- 2017-01-16T22:10:58+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r11459 r11469 1009 1009 g.setStroke(new BasicStroke(outlineWidth)); 1010 1010 1011 int lastPixel Y= 0;1011 int lastPixelX = 0; 1012 1012 int lastPixelColor = 0; 1013 1013 1014 1014 // resample gray scale image with line linear weight of next sample in line 1015 1015 // process each line and draw pixels / rectangles with same color with one operations 1016 for (int x = 0; x < maxPixelX; x += offX) { 1017 for (int y = 0; y < maxPixelY; y += offY) { 1018 1019 int thePixelColor = 0; 1016 for (int y = 0; y < maxPixelY; y += offY) { 1017 1018 // the lines offsets 1019 final int lastLineOffset = maxPixelX * (y+0); 1020 final int nextLineOffset = maxPixelX * (y+1); 1021 1022 for (int x = 0; x < maxPixelX; x += offX) { 1023 1024 int thePixelColor = 0; int thePixelCount = 0; 1020 1025 1021 1026 // sample the image (it is gray scale) 1022 int offset = (x * maxPixelX) + y;1027 int offset = lastLineOffset + x; 1023 1028 1024 1029 // merge next pixels of window of line 1025 for (int k = 0; k < offX && offset + k < imgPixels.length; k++) {1030 for (int k = 0; k < offX && (offset + k) < nextLineOffset; k++) { 1026 1031 thePixelColor += imgPixels[offset+k] & 0xFF; 1032 thePixelCount++; 1027 1033 } 1028 1034 1029 1035 // mean value 1030 thePixelColor /= offX;1036 thePixelColor = thePixelCount > 0 ? (thePixelColor / thePixelCount) : 0; 1031 1037 1032 1038 // restart -> use initial sample 1033 if (0 == y) {1034 lastPixel Y= 0; lastPixelColor = thePixelColor - 1;1039 if (0 == x) { 1040 lastPixelX = 0; lastPixelColor = thePixelColor - 1; 1035 1041 } 1036 1042 … … 1056 1062 // box from from last Y pixel to current pixel 1057 1063 if (drawOutlines) { 1058 g.drawRect(lastPixel Y, x, offY + y- lastPixelY, offX);1064 g.drawRect(lastPixelX, y, offX + x - lastPixelX, offY); 1059 1065 } else { 1060 g.fillRect(lastPixel Y, x, offY + y- lastPixelY, offX);1066 g.fillRect(lastPixelX, y, offX + x - lastPixelX, offY); 1061 1067 } 1062 1068 } 1063 1069 1064 1070 // restart detection 1065 lastPixel Y = y; lastPixelColor = thePixelColor;1071 lastPixelX = x; lastPixelColor = thePixelColor; 1066 1072 } 1067 1073 } … … 1081 1087 1082 1088 // get bounds of screen image and projection, zoom and adjust input parameters 1083 final Rectangle screenBounds = g.getDeviceConfiguration().getBounds();1089 final Rectangle screenBounds = new Rectangle(mv.getWidth(), mv.getHeight()); 1084 1090 final double zoomScale = mv.getScale(); 1085 1091 … … 1088 1094 1089 1095 // 1st setup virtual paint area ---------------------------------------- 1090 1091 // HACK: sometime screen bounds does not return valid values when picture is shifted1092 // therefore we use a bigger area to avoid missing parts of image1093 screenBounds.width = screenBounds.width * 3 / 2;1094 screenBounds.height = screenBounds.height * 3 / 2;1095 1096 1096 1097 // new image buffer needed … … 1142 1143 heatMapCacheVisibleSegments = visibleSegments.size(); 1143 1144 heatMapCacheZoomScale = zoomScale; 1144 heatMapCacheLineWith = lineWidth;1145 heatMapCacheLineWith = globalLineWidth; 1145 1146 } 1146 1147 1147 1148 // 4th. Draw data on target layer, map data via color lookup table -------------- 1148 drawHeatMapGrayMap(g, heatMapImgGray, 1149 lineWidthB > 2 ? (lineWidthB / 2) : 1, 1150 lineWidth > 2 ? (lineWidth - 2) : 1); 1149 drawHeatMapGrayMap(g, heatMapImgGray, lineWidthB > 2 ? (lineWidthB / 2) : 1, lineWidth > 2 ? (lineWidth - 2) : 1); 1151 1150 } 1152 1151
Note:
See TracChangeset
for help on using the changeset viewer.