Convert the pixels to sips, based on density scale.
@param context the context.
@param pixels to be converted value.
@return converted value(sip)
426766
public static float pixelToSip(Context context, float pixels) {
        DisplayMetrics metrics = new DisplayMetrics();
        float scaledDensity = metrics.scaledDensity;
        if (pixels == 0 || scaledDensity == 0) {
            return 1;
        }
        return pixels/scaledDensity;
    }
122685
def setPixelScale(self, pxms):
        
        pxms = float(pxms)/2
        self.pixelsPerms = pxms
        if pxms*self.gridms < GRID_PIXEL_MIN:
            self.gridms = self.gridms*2
        elif pxms*self.gridms > GRID_PIXEL_MAX:
            self.gridms = self.gridms/2
        self._viewIsDirty = True
        self.viewport().update()

        return self.gridms
1219299
public static JCGLPixelFormat pixelTypeFromGL(
    final int e)
  {
    switch (e) {
      case GL.GL_UNSIGNED_INT_24_8:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_INT_24_8;
      case GL.GL_UNSIGNED_SHORT_5_6_5:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_565;
      case GL.GL_UNSIGNED_SHORT_5_5_5_1:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_5551;
      case GL.GL_UNSIGNED_SHORT_4_4_4_4:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_4444;
      case GL2ES2.GL_UNSIGNED_INT_10_10_10_2:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_INT_1010102;
      case GL.GL_UNSIGNED_SHORT:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_SHORT;
      case GL.GL_UNSIGNED_INT:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_INT;
      case GL.GL_UNSIGNED_BYTE:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_BYTE;
      case GL.GL_SHORT:
        return JCGLPixelFormat.PIXEL_COMPONENT_SHORT;
      case GL2ES2.GL_INT:
        return JCGLPixelFormat.PIXEL_COMPONENT_INT;
      case GL.GL_FLOAT:
        return JCGLPixelFormat.PIXEL_COMPONENT_FLOAT;
      case GL.GL_BYTE:
        return JCGLPixelFormat.PIXEL_COMPONENT_BYTE;
      case GL.GL_HALF_FLOAT:
        return JCGLPixelFormat.PIXEL_COMPONENT_HALF_FLOAT;
      default:
        throw new UnreachableCodeException();
    }
  }
870732
protected Double getBilinearInterpolationValue(
			CoverageDataSourcePixel sourcePixelX,
			CoverageDataSourcePixel sourcePixelY, Double[][] values) {
		return getBilinearInterpolationValue(sourcePixelX.getOffset(),
				sourcePixelY.getOffset(), sourcePixelX.getMin(),
				sourcePixelX.getMax(), sourcePixelY.getMin(),
				sourcePixelY.getMax(), values);
	}
1090105
public static int dp2px(Context context, float dpVal) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                dpVal, context.getResources().getDisplayMetrics());
    }
773794
public static JCGLPixelFormat pixelTypeFromGL(
    final int e)
  {
    switch (e) {
      case GL30.GL_UNSIGNED_INT_24_8:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_INT_24_8;
      case GLES20.GL_UNSIGNED_SHORT_5_6_5:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_565;
      case GLES20.GL_UNSIGNED_SHORT_5_5_5_1:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_5551;
      case GLES20.GL_UNSIGNED_SHORT_4_4_4_4:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_4444;
      case GL12.GL_UNSIGNED_INT_10_10_10_2:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_INT_1010102;
      case GL11.GL_UNSIGNED_SHORT:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_SHORT;
      case GL11.GL_UNSIGNED_INT:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_INT;
      case GL11.GL_UNSIGNED_BYTE:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_BYTE;
      case GL11.GL_SHORT:
        return JCGLPixelFormat.PIXEL_COMPONENT_SHORT;
      case GL11.GL_INT:
        return JCGLPixelFormat.PIXEL_COMPONENT_INT;
      case GL11.GL_FLOAT:
        return JCGLPixelFormat.PIXEL_COMPONENT_FLOAT;
      case GL11.GL_BYTE:
        return JCGLPixelFormat.PIXEL_COMPONENT_BYTE;
      case GL30.GL_HALF_FLOAT:
        return JCGLPixelFormat.PIXEL_COMPONENT_HALF_FLOAT;
      default:
        throw new UnreachableCodeException();
    }
  }
76351
public static int dpToPx(Context context, float dp) {
    DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    return (int) ((dp * displayMetrics.density) + 0.5);
  }
691808
function(context) {
            var devicePixelRatio = window.devicePixelRatio || 1,
                backingStoreRatio =
                context.webkitBackingStorePixelRatio ||
                context.mozBackingStorePixelRatio ||
                context.msBackingStorePixelRatio ||
                context.oBackingStorePixelRatio ||
                context.backingStorePixelRatio || 1;
            return devicePixelRatio / backingStoreRatio;
        }
887620
public static int pixelYToTileY(double pixelY, byte zoomLevel, int tileSize) {
        return (int) Math.min(Math.max(pixelY / tileSize, 0), Math.pow(2, zoomLevel) - 1);
    }
591162
public int ZoomForPixelSize( int pixelSize ) {
        for( int i = 0; i < 30; i++ ) {
            if (pixelSize > Resolution(i)) {
                if (i != 0) {
                    return i - 1;
                } else {
                    return 0; // We don't want to scale up
                }
            }
        }
        return 0;
    }
310653
private void process(int[] srcImage, int[] dstImage, int x, int y)
    {
        final int b = getSourcePixel(srcImage, x, y - 1);
        final int d = getSourcePixel(srcImage, x - 1, y);
        final int e = getSourcePixel(srcImage, x, y);
        final int f = getSourcePixel(srcImage, x + 1, y);
        final int h = getSourcePixel(srcImage, x, y + 1);
        int e0 = e;
        int e1 = e;
        int e2 = e;
        int e3 = e;
        if (b != h && d != f)
        {
            e0 = d == b ? d : e;
            e1 = b == f ? f : e;
            e2 = d == h ? d : e;
            e3 = h == f ? f : e;
        }

        setDestPixel(dstImage, x * SCALE, y * SCALE, e0);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE, e1);
        setDestPixel(dstImage, x * SCALE, y * SCALE + 1, e2);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE + 1, e3);
    }
1076596
public static float px2dp(Context context, float pxVal) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (pxVal / scale);
    }
1374560
public double[] PixelsToMeters( double px, double py, int zoom ) {
        double res = Resolution(zoom);
        double mx = px * res - originShift;
        double my = py * res - originShift;
        return new double[]{mx, my};
    }
43615
public static ContentProviderSimpleAdapter getInternalPhotoSimpleAdapter(Context context) {
    return new ContentProviderSimpleAdapter(MediaStore.Images.Media.INTERNAL_CONTENT_URI, context);
  }
83778
def pixel(self, x, y, size=None):
        """"""
        if (size is None):
            size = self.sz
        # Have we go to the smallest element?
        if (size <= 3):
            if (_middle(x, y)):
                return (None)
            else:
                return (0, 0, 0)
        divisor = size // 3
        if (_middle(x // divisor, y // divisor)):
            return None
        return self.pixel(x % divisor, y % divisor, divisor)
232007
public Pixel[] pixels() {
        Pixel[] pixels = new Pixel[count()];
        Point[] points = points();
        for (int k = 0; k < points.length; k++) {
            pixels[k] = pixel(points[k]);
        }
        return pixels;
    }
701148
private double valueToPixelValue(GriddedTile griddedTile, double value) {

		double pixelValue = value;

		if (griddedCoverage != null
				&& griddedCoverage.getDataType() == GriddedCoverageDataType.INTEGER) {

			pixelValue -= griddedCoverage.getOffset();
			pixelValue /= griddedCoverage.getScale();
			if (griddedTile != null) {
				pixelValue -= griddedTile.getOffset();
				pixelValue /= griddedTile.getScale();
			}

		}

		return pixelValue;
	}