Get the pixel dimensions of a video.
    @param p_mi: media player.
    @param num: number of the video (starting from, and most commonly 0).
    @return: px pixel width, py pixel height.
549147
def libvlc_video_get_size(p_mi, num):
    '''
    '''
    f = _Cfunctions.get('libvlc_video_get_size', None) or \
        _Cfunction('libvlc_video_get_size', ((1,), (1,), (2,), (2,),), None,
                    ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
    return f(p_mi, num)
1355995
def get_region_size(region):
        
        if region is None:
            return 180.
        tokens = parse_hpxregion(region)
        if tokens[0] in ['DISK', 'DISK_INC']:
            return float(tokens[3])
        elif tokens[0] == 'HPX_PIXEL':
            pixel_size = get_pixel_size_from_nside(int(tokens[2]))
            return 2. * pixel_size
        else:
            raise Exception(
                "HPX.get_region_size did not recognize region type %s" % tokens[0])
        return None
972650
def pix2canvas(self, pt):
        
        x, y = pt[:2]
        #print('p2c in', x, y)
        mm = gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX)
        pm = gl.glGetDoublev(gl.GL_PROJECTION_MATRIX)
        vp = gl.glGetIntegerv(gl.GL_VIEWPORT)

        win_x, win_y = float(x), float(vp[3] - y)
        win_z = gl.glReadPixels(int(win_x), int(win_y), 1, 1,
                                gl.GL_DEPTH_COMPONENT, gl.GL_FLOAT)
        pos = glu.gluUnProject(win_x, win_y, win_z, mm, pm, vp)
        #print('out', pos)
        return pos
1042364
def libvlc_video_set_crop_geometry(p_mi, psz_geometry):
    '''
    '''
    f = _Cfunctions.get('libvlc_video_set_crop_geometry', None) or \
        _Cfunction('libvlc_video_set_crop_geometry', ((1,), (1,),), None,
                    None, MediaPlayer, ctypes.c_char_p)
    return f(p_mi, psz_geometry)
935644
def load_pixel_data(dcm)
      raise ArgumentError, "Invalid argument 'dcm'. Expected DObject, got #{dcm.class}." unless dcm.is_a?(DICOM::DObject)
      raise ArgumentError, "Invalid argument 'dcm'. Expected modality 'CR', got #{dcm.value(MODALITY)}." unless dcm.value(MODALITY) == 'CR'
      # Set attributes common for all image modalities, i.e. CT, MR, RTDOSE & RTIMAGE:
      @dcm = dcm
      @narray = dcm.narray
      @date = dcm.value(IMAGE_DATE)
      @time = dcm.value(IMAGE_TIME)
      @columns = dcm.value(COLUMNS)
      @rows = dcm.value(ROWS)
      spacing = dcm.value(SPACING).split("\\")
      raise "Invalid DICOM image: 2 basckslash-separated values expected for Pixel Spacing, got: #{spacing}" unless spacing.length == 2
      @col_spacing = spacing[1].to_f
      @row_spacing = spacing[0].to_f
    end
1296007
def size(self):
        
        N = self.nmax + 1;
        NC = N + self.mmax * (2 * N - self.mmax - 1);
        assert NC == len(self._vec)
        return NC
184098
def convert_pnm(self, infile, outfile):
        

        if self.interlace:
            pixels = array('B')
            pixels.fromfile(infile,
                            (self.bitdepth/8) * self.color_planes *
                            self.width * self.height)
            self.write_passes(outfile, self.array_scanlines_interlace(pixels))
        else:
            self.write_passes(outfile, self.file_scanlines(infile))
727501
def pixelFormat(self):
        
        f=None
        if self.isVideo():
            if self.__dict__['pix_fmt']:
                f=self.__dict__['pix_fmt']
        return f
625927
def libvlc_video_get_spu(p_mi):
    '''
    '''
    f = _Cfunctions.get('libvlc_video_get_spu', None) or \
        _Cfunction('libvlc_video_get_spu', ((1,),), None,
                    ctypes.c_int, MediaPlayer)
    return f(p_mi)
1030924
public float getPixelSize() {
    if (mVectorState == null && mVectorState.mVPathRenderer == null ||
        mVectorState.mVPathRenderer.mBaseWidth == 0 ||
        mVectorState.mVPathRenderer.mBaseHeight == 0 ||
        mVectorState.mVPathRenderer.mViewportHeight == 0 ||
        mVectorState.mVPathRenderer.mViewportWidth == 0) {
      return 1; // fall back to 1:1 pixel mapping.
    }
    float intrinsicWidth = mVectorState.mVPathRenderer.mBaseWidth;
    float intrinsicHeight = mVectorState.mVPathRenderer.mBaseHeight;
    float viewportWidth = mVectorState.mVPathRenderer.mViewportWidth;
    float viewportHeight = mVectorState.mVPathRenderer.mViewportHeight;
    float scaleX = viewportWidth / intrinsicWidth;
    float scaleY = viewportHeight / intrinsicHeight;
    return Math.min(scaleX, scaleY);
  }
27848
def _get_fixed_params(im):
    
    
    p = Parameters()
    
    if not isinstance(im, np.ndarray):
        return p
    
    # Dimension of the inputs
    p.FixedImageDimension = im.ndim
    p.MovingImageDimension = im.ndim
    
    # Always write result, so I can verify
    p.WriteResultImage = True
    
    # How to write the result
    tmp = DTYPE_NP2ITK[im.dtype.name]
    p.ResultImagePixelType = tmp.split('_')[-1].lower()
    p.ResultImageFormat = "mhd"
    
    # Done
    return p
368706
def convert_ppm_and_pgm(self, ppmfile, pgmfile, outfile):
        
        pixels = array('B')
        pixels.fromfile(ppmfile,
                        (self.bitdepth/8) * self.color_planes *
                        self.width * self.height)
        apixels = array('B')
        apixels.fromfile(pgmfile,
                         (self.bitdepth/8) *
                         self.width * self.height)
        pixels = interleave_planes(pixels, apixels,
                                   (self.bitdepth/8) * self.color_planes,
                                   (self.bitdepth/8))
        if self.interlace:
            self.write_passes(outfile, self.array_scanlines_interlace(pixels))
        else:
            self.write_passes(outfile, self.array_scanlines(pixels))
878437
def libvlc_media_player_get_length(p_mi):
    '''
    '''
    f = _Cfunctions.get('libvlc_media_player_get_length', None) or \
        _Cfunction('libvlc_media_player_get_length', ((1,),), None,
                    ctypes.c_longlong, MediaPlayer)
    return f(p_mi)
1138711
def with_added_dimensions(self, n):
        
        if n > 0:
            return Rect(np.pad(self.data, ((0, 0), (0, n)), 'constant'))
        return Rect(self.data[:, :self.dimensions + n])
426269
public static int pixelTypeToGL(
    final JCGLPixelFormat p)
  {
    switch (p) {
      case PIXEL_COMPONENT_BYTE:
        return GL11.GL_BYTE;
      case PIXEL_COMPONENT_FLOAT:
        return GL11.GL_FLOAT;
      case PIXEL_COMPONENT_INT:
        return GL11.GL_INT;
      case PIXEL_COMPONENT_SHORT:
        return GL11.GL_SHORT;
      case PIXEL_COMPONENT_UNSIGNED_BYTE:
        return GL11.GL_UNSIGNED_BYTE;
      case PIXEL_COMPONENT_UNSIGNED_INT:
        return GL11.GL_UNSIGNED_INT;
      case PIXEL_COMPONENT_UNSIGNED_SHORT:
        return GL11.GL_UNSIGNED_SHORT;
      case PIXEL_PACKED_UNSIGNED_INT_1010102:
        return GL12.GL_UNSIGNED_INT_10_10_10_2;
      case PIXEL_PACKED_UNSIGNED_SHORT_4444:
        return GLES20.GL_UNSIGNED_SHORT_4_4_4_4;
      case PIXEL_PACKED_UNSIGNED_SHORT_5551:
        return GLES20.GL_UNSIGNED_SHORT_5_5_5_1;
      case PIXEL_PACKED_UNSIGNED_SHORT_565:
        return GLES20.GL_UNSIGNED_SHORT_5_6_5;
      case PIXEL_COMPONENT_HALF_FLOAT:
        return GL30.GL_HALF_FLOAT;
      case PIXEL_PACKED_UNSIGNED_INT_24_8:
        return GL30.GL_UNSIGNED_INT_24_8;
    }

    throw new UnreachableCodeException();
  }
20475
function dimensions(buffer) {
    var mp28 = Math.pow(2,8);
    switch (type(buffer)) {
    case 'png':
        var i = 8;
        while (i < buffer.length) {
            var length = buffer.readUInt32BE(i);
            var chunktype = buffer.toString('ascii', i + 4, i + 8);
            // Invalid chunk.
            if (!(length || chunktype === 'IEND')) return false;
            // Length + type.
            i += 8;
            if (chunktype === 'IHDR') {
                var w = (buffer[i+0]*Math.pow(2,32)) + (buffer[i+1]*Math.pow(2,16)) + (buffer[i+2]*Math.pow(2,8)) + buffer[i+3];
                var h = (buffer[i+4]*Math.pow(2,32)) + (buffer[i+5]*Math.pow(2,16)) + (buffer[i+6]*Math.pow(2,8)) + buffer[i+7];
                return [w,h];
            }
            // Skip CRC.
            i += length + 4;
        }
        break;
    case 'jpg':
        var i = 2;
        while (i < buffer.length) {
            // Invalid chunk.
            if (buffer[i] !== 0xff) return false;
            var chunktype = buffer[i+1];
            var length = (buffer[i+2]*mp28) + (buffer[i+3]);
            // Entropy-encoded begins after this chunk. Bail.
            if (chunktype === 0xda) {
                return false;
            } else if (chunktype === 0xc0) {
                var h = (buffer[i+5]*Math.pow(2,8)) + buffer[i+6];
                var w = (buffer[i+7]*Math.pow(2,8)) + buffer[i+8];
                return [w,h];
            }
            i += 2 + length;
        }
        break;
    case 'gif':
        var w = (buffer[7]*Math.pow(2,8)) + buffer[6];
        var h = (buffer[9]*Math.pow(2,8)) + buffer[8];
        return [w,h];
        break;
    case 'webp':
        var chunktype = buffer.toString('ascii', 12, 16);
        if (chunktype === 'VP8 ') {
            // Invalid chunk.
            if (buffer[23] !== 0x9d || buffer[24] !== 0x01 || buffer[25] !== 0x2a) return false;
            var w = buffer[26] | (buffer[27] << 8);
            var h = buffer[28] | (buffer[29] << 8);
            return [w,h];
        }
        else if (chunktype === 'VP8L') {
            var w = 1 + (buffer[21] | (buffer[22] & 0x3F) << 8);
            var h = 1 + (((buffer[22] & 0xC0) >> 6) | (buffer[23] << 2) | ((buffer[24] & 0xF) << 10));
            return [w,h];
        }
        else  if (chunktype === 'VP8X') {
            var w = 1 + (buffer[24] | buffer[25] << 8 | buffer[26] << 16);
            var h = 1 + (buffer[27] | buffer[28] << 8 | buffer[29] << 16);

            return [w,h];
        }
        return false;
        break;
    }
    return false;
}
746398
public static int computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels) {
        int initialSize = computeInitialSampleSize(options, minSideLength, maxNumOfPixels);
        int roundedSize;
        if (initialSize <= 8) {
            roundedSize = 1;
            while (roundedSize < initialSize) {
                roundedSize <<= 1;
            }
        } else {
            roundedSize = (initialSize + 7) / 8 * 8;
        }
        return roundedSize;
    }