Returns a Frame based on a BufferedImage, given gamma, and inverted channels flag.
506957
public Frame getFrame(BufferedImage image, double gamma, boolean flipChannels) {
		if (image == null) {
			return null;
		}
		SampleModel sm = image.getSampleModel();
		int depth = 0, numChannels = sm.getNumBands();
		switch (image.getType()) {
			case BufferedImage.TYPE_INT_RGB:
			case BufferedImage.TYPE_INT_ARGB:
			case BufferedImage.TYPE_INT_ARGB_PRE:
			case BufferedImage.TYPE_INT_BGR:
				depth = Frame.DEPTH_UBYTE;
				numChannels = 4;
				break;
		}
		if (depth == 0 || numChannels == 0) {
			switch (sm.getDataType()) {
				case DataBuffer.TYPE_BYTE:   depth = Frame.DEPTH_UBYTE;  break;
				case DataBuffer.TYPE_USHORT: depth = Frame.DEPTH_USHORT; break;
				case DataBuffer.TYPE_SHORT:  depth = Frame.DEPTH_SHORT;  break;
				case DataBuffer.TYPE_INT:    depth = Frame.DEPTH_INT;    break;
				case DataBuffer.TYPE_FLOAT:  depth = Frame.DEPTH_FLOAT;  break;
				case DataBuffer.TYPE_DOUBLE: depth = Frame.DEPTH_DOUBLE; break;
				default: assert false;
			}
		}
		if (frame == null || frame.imageWidth != image.getWidth() || frame.imageHeight != image.getHeight()
				|| frame.imageDepth != depth || frame.imageChannels != numChannels) {
			frame = new Frame(image.getWidth(), image.getHeight(), depth, numChannels);
		}
		copy(image, frame, gamma, flipChannels, null);
		return frame;
	}
192882
public AmqpFrame getFrame()
    {    
        int pos = this.position();       
        AmqpMethod method = new AmqpMethod();
        int classIndex;
        AmqpFrame frame = new AmqpFrame(); 
                 
        // If there is at least one Frame in the buffer, attempt to decode it.
        if (this.remaining() > 7)
        {            
            frame.setHeader(this.getFrameHeader());           
            frame.setChannelId((short) frame.getHeader().channel);           
            frame.setType((short) frame.getHeader().frameType);           
            // the buffer must have an additional byte for the Frame end marker 
            
            if (this.remaining() >= frame.getHeader().size + 1)
            {                
                switch (frame.getType())
                {                
                    case AmqpConstants.FRAME_BODY:                        
                        WrappedByteBuffer body = new AmqpBuffer();
                        // copy body into new Buffer
                        int end = this.position() + (int)frame.getHeader().size;
                        while (position() < end)
                        {
                            body.put(get());
                        }
                        frame.setBody(body);
                        frame.setMethodName("body");                        
                        break;

                    case AmqpConstants.FRAME_HEADER:                        
                        classIndex = this.getUnsignedShort();
                        @SuppressWarnings("unused")
                        short weight = (short)this.getUnsignedShort();
                        @SuppressWarnings("unused")
                        long bodySize = this.getUnsignedLong();                            
                        
                        frame.setContentProperties(this.getContentProperties());
                        frame.setMethodName("header");                        
                        break;

                    case AmqpConstants.FRAME_METHOD:
                         classIndex = this.getUnsignedShort();
                        int methodIndex = this.getUnsignedShort();
                        String indexes = String.valueOf(classIndex) + String.valueOf(methodIndex);                      
                        method = MethodLookup.LookupMethod(indexes);
                        
                        // pull parameter list off of method
                        List<Parameter> params = method.allParameters;

                        frame.setMethodName(method.name);
                        frame.setArgs(this.getMethodArguments(params));                        
                        break;

                    case AmqpConstants.FRAME_HEARTBEAT:
                    case AmqpConstants.FRAME_RABBITMQ_HEARTBEAT:
                    	throw new IllegalStateException("Received heartbeat frame even though the client has expressed no interest in heartbeat via tune-ok method.");

                    default:
                    	throw new IllegalStateException("Unrecognized AMQP 0-9-1 Frame type = " + frame.getType());
                }
                
                short frameEnd = (short) this.getUnsigned();                
                if (frameEnd != AmqpConstants.FRAME_END)
                {                    
                    throw new IllegalStateException("Invalid end of AMQP method frame");
                }
            }
            else
            {                
                this.position(pos);
                return null;
            }
            return frame;
        }
        return null;
    }
902833
def frame
      return @frame if @frame

      chars = []
      # 4 corners
      chars << Char.new(0x23, @x_offset - 1, @y_offset - 1)               # TopLeft
      chars << Char.new(0x23, @x_offset + @width, @y_offset - 1)          # TopRight
      chars << Char.new(0x23, @x_offset - 1, @y_offset + @height)         # BottomLeft
      chars << Char.new(0x23, @x_offset + @width, @y_offset  + @height)   # BottomRight

      # horiz
      @width.times { |x| chars << Char.new(0x2d, x + @x_offset, @y_offset - 1) }
      @width.times { |x| chars << Char.new(0x2d, x + @x_offset, @y_offset + @height) }

      # vertical
      @height.times { |y| chars << Char.new(0x7c, @x_offset - 1, y + @y_offset) }
      @height.times { |y| chars << Char.new(0x7c, @x_offset + @width, y + @y_offset) }
      @frame = ""
      @frame << chars.join
    end
444911
def _pdb_frame(self):
        """"""
        if self._pdb_obj is not None and self._pdb_obj.curframe is not None:
            return self._pdb_obj.curframe
899611
def _frombuffer(ptr, frames, channels, dtype):
    """"""
    framesize = channels * dtype.itemsize
    data = np.frombuffer(ffi.buffer(ptr, frames * framesize), dtype=dtype)
    data.shape = -1, channels
    return data
1013259
def decode_jpeg(image_buffer, scope=None):
  
  with tf.name_scope(values=[image_buffer], name=scope,
                     default_name='decode_jpeg'):
    # Decode the string as an RGB JPEG.
    # Note that the resulting image contains an unknown height and width
    # that is set dynamically by decode_jpeg. In other words, the height
    # and width of image is unknown at compile-time.
    image = tf.image.decode_jpeg(image_buffer, channels=3)

    # After this point, all image pixels reside in [0,1)
    # until the very end, when they're rescaled to (-1, 1).  The various
    # adjust_* ops all require this range for dtype float.
    image = tf.image.convert_image_dtype(image, dtype=tf.float32)
    return image
1136858
public BufferedImage asBufferedImage(INDArray array, int dataType) {
        return converter2.convert(asFrame(array, dataType));
    }
1233343
public static BufferedImage ByteBufferImage( byte[] data, int width, int height ) {
        int[] bandoffsets = {0, 1, 2, 3};
        DataBufferByte dbb = new DataBufferByte(data, data.length);
        WritableRaster wr = Raster.createInterleavedRaster(dbb, width, height, width * 4, 4, bandoffsets, null);
        int[] bitfield = {8, 8, 8, 8};

        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        ColorModel cm = new ComponentColorModel(cs, bitfield, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);

        return new BufferedImage(cm, wr, false, null);
    }
1221773
def preprocess_frame(frame):
  
  # Normalize from [0.0, 1.0] -> [-0.5, 0.5]
  frame = common_layers.convert_rgb_to_real(frame)
  frame = frame - 0.5
  frame, _ = glow_ops.uniform_binning_correction(frame)
  return frame
734830
def _original_frame(self, x, y):
        
        if self._inverted:
            return self.obs.naxis1 - x, self.obs.naxis2 - y
        return x, y
316979
public static BufferedImage toBufferedImage(Image img) {
		if (img instanceof BufferedImage) {
			return (BufferedImage) img;
		}

		return copyImage(img, BufferedImage.TYPE_INT_RGB);
	}
193472
def get_frame_src(f:Frame) -> str:
    ''' 
    '''
    path, line, src, fn = _get_frame(
        inspect.getframeinfo(f)
    )
    return '{}:{} -> {}\n{}'.format(
        path.split(os.sep)[-1],
        line,
        fn,
        repr(src[0][:-1]) # shave off \n
    )
864266
public BufferedImage getBufferedImage(int width, int height) {
		BufferedImage bi = chart.createBufferedImage(width, height);
		return bi;
	}
877267
def detect_framebuffer(self, glo=None) -> 'Framebuffer':
        '''
            
        '''

        res = Framebuffer.__new__(Framebuffer)
        res.mglo, res._size, res._samples, res._glo = self.mglo.detect_framebuffer(glo)
        res._color_attachments = None
        res._depth_attachment = None
        res.ctx = self
        res.extra = None
        return res
393263
def _get_framed(self, buf, offset, insert_payload):
    
    header_offset = offset + self._header_len
    self.length = insert_payload(buf, header_offset, self.payload)
    struct.pack_into(self._header_fmt,
                     buf,
                     offset,
                     self.preamble,
                     self.msg_type,
                     self.sender,
                     self.length)
    crc_offset = header_offset + self.length
    preamble_bytes = 1
    crc_over_len = self._header_len + self.length - preamble_bytes
    self.crc = crc16jit(buf, offset+1, 0, crc_over_len)
    struct.pack_into(self._crc_fmt, buf, crc_offset, self.crc)
    length = preamble_bytes + crc_over_len + self._crc_len
    return length
554339
public static void bufferedToGray(DataBufferInt buffer, WritableRaster src, GrayU8 dst) {
		int[] srcData = buffer.getData();

		byte[] data = dst.data;

		int srcStride = stride(src);
		int srcOffset = getOffset(src);


		//CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.height, y -> {
		for (int y = 0; y < dst.height; y++) {
			int indexSrc = srcOffset + y*srcStride;
			int indexDst = dst.startIndex + y * dst.stride;
			for (int x = 0; x < dst.width; x++) {

				int rgb = srcData[indexSrc++];

				int r = (rgb >>> 16) & 0xFF;
				int g = (rgb >>> 8) & 0xFF;
				int b = rgb & 0xFF;

				int ave = (r + g + b) / 3;

				data[indexDst++] = (byte) ave;
			}
		}
		//CONCURRENT_ABOVE });
	}
111450
def latents_to_frames(z_top_interp, level_eps_interp, hparams):
  """"""
  # Decode [z^1_t, z^2_t .. z^l_t] to [X_t]
  images, _, _, _ = glow_ops.encoder_decoder(
      "codec", z_top_interp, hparams, eps=level_eps_interp, reverse=True)
  images = glow_ops.postprocess(images)
  return images