⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memoryimagesource.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
字号:
/** * MemoryImageSource -  * * Copyright (c) 1998 *      Transvirtual Technologies, Inc.  All rights reserved. * Copyright (c) 2006 *      Kaffe.org developers. See ChangeLog for details. * * See the file "license.terms" for information on usage and redistribution  * of this file.  * * original code P.C.Mehlitz * some code taken or adapted from Classpath */package java.awt.image;import java.util.Hashtable;import java.util.Vector;import org.kaffe.awt.JavaColorModel;public class MemoryImageSource  implements ImageProducer{	Vector consumers = new Vector(3);	Hashtable props;	int width;	int height;	int scan;	int offset;	int[] ipels;	byte[] bpels;	ColorModel model;	boolean animated;	boolean fullbuffers;public MemoryImageSource( int w, int h, ColorModel cm, byte[] pix, int off, int scan) {	this( w, h, cm, pix, off, scan, null);}public MemoryImageSource( int w, int h, ColorModel cm, byte[] pix, int off, int scan, Hashtable props) {	this.width  = w;	this.height = h;	this.bpels  = pix;	this.model  = cm;	this.offset = off;	this.scan   = scan;	this.props  = props;}public MemoryImageSource( int w, int h, ColorModel cm, int[] pix, int off, int scan) {	this( w, h, cm, pix, off, scan, null);}public MemoryImageSource( int w, int h, ColorModel cm, int[] pix, int off, int scan, Hashtable props) {	this.width  = w;	this.height = h;	this.ipels  = pix;	this.model  = cm;	this.offset = off;	this.scan   = scan;	this.props  = props;}public MemoryImageSource( int w, int h, int[] pix, int off, int scan) {	this( w, h, JavaColorModel.getSingleton(), pix, off, scan, null);}public MemoryImageSource( int w, int h, int[] pix, int off, int scan, Hashtable props) {	this( w, h, JavaColorModel.getSingleton(), pix, off, scan, props);}public void addConsumer( ImageConsumer ic) {	if ( ! consumers.contains( ic) ) {		consumers.addElement( ic);	}}private void initializeConsumer( ImageConsumer ic) {	ic.setDimensions( width, height);		ic.setColorModel( model);	ic.setProperties( props);	ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT | ImageConsumer.SINGLEPASS | ImageConsumer.SINGLEFRAME | ImageConsumer.COMPLETESCANLINES);}public boolean isConsumer( ImageConsumer ic) {	return consumers.contains( ic);}public void newPixels() {	newPixels( 0, 0, width, height, true);}public void newPixels( byte[] newpix, ColorModel newmodel, int offset, int scansize) {	this.ipels  = null;	this.bpels  = newpix;	this.model  = newmodel;	this.offset = offset;	this.scan   = scansize;	newPixels();}public void newPixels( int x, int y, int w, int h) {	newPixels( x, y, w, h, true);}public void newPixels( int x, int y, int w, int h, boolean framenotify) {	if ( ! animated ) {		return;	}	if ( fullbuffers ) {		x = 0;		y = 0;		w = width;		h = height;	}	int sz = consumers.size();	for ( int i = 0; i < sz; i++) {		ImageConsumer ic = (ImageConsumer) consumers.elementAt( i);		transferPels( ic, x, y, w, h);		if ( framenotify && isConsumer( ic) ) {			ic.setHints( ImageConsumer.SINGLEFRAMEDONE);		}	}}public void newPixels( int[] newpix, ColorModel newmodel, int offset, int scansize) {	this.bpels  = null;	this.ipels  = newpix;	this.model  = newmodel;	this.offset = offset;	this.scan   = scansize;	newPixels();}public void removeConsumer( ImageConsumer ic) {	consumers.removeElement( ic);}public void requestTopDownLeftRightResend( ImageConsumer ic) {}public void setAnimated( boolean animated) {	this.animated = animated;	if ( ! animated ) {		for ( int i=0; i<consumers.size(); i++) {			ImageConsumer ic = (ImageConsumer) consumers.elementAt( i);			ic.imageComplete( ImageConsumer.STATICIMAGEDONE);		}		consumers.removeAllElements();	}}public void setFullBufferUpdates( boolean fullbuffers) {	this.fullbuffers = fullbuffers;}public void startProduction( ImageConsumer ic) {	addConsumer(ic);	initializeConsumer(ic);	transferPels(ic, 0, 0, width, height);	terminateConsumer(ic);}private void terminateConsumer(ImageConsumer ic) {	ic.imageComplete(ImageConsumer.STATICIMAGEDONE);}private void transferPels( ImageConsumer ic, int x, int y, int w, int h) {	if ( bpels != null ) {		ic.setPixels( x, y, w, h, model, bpels, offset, scan );	}	else if ( ipels != null ) {		ic.setPixels( x, y, w, h, model, ipels, offset, scan );	}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -