Java JPEG GIF. JPEG , , , GIF , , ..
. , . , , , , .
. , :
/* <title>SimpleImageLoad</title>
*<applet code="SimpleImageLoad" width=300 height=150>
* <param name="img" value="mupk.gif">
* </applet>
*/
import java.applet.*;
import java.awt.*;
public class SimpleImageLoad extends Applet {
Image art;
public void init() {
art = getImage(getDocumentBase(), getParameter("img"));
}
public void paint(Graphics g) {
g.drawImage(art, 0, 0, this);
} }
paint drawlmage : art, , ImageObserver. ImageObserver ; this ImageObserver, . , init art. SimpleImageLoad.html, ImageObserver paint . ImageObserver , .
ImageObserver
ImageObserver , , imageUpdate ImageObserver , . , , , . ImageObserver Applet implement ImageObserver, :
public class MyApplet extends Applet implement ImageObserver {
imageUpdate ImageObserver, :
public boolean imageUpdate(Image img, int status,
int x, int int width, int height) {
if((status & ALLBITS) != 1) {
System.out.println("Still processing the image");
return true;
}
else {
System.out.println("Done processing the image");
return false;
} }
imageUpdate Image, , status, , (x, , width, height), , . ImageUpdate false true .
status . , , :
WIDTH |
width. |
HEIGHT |
height. |
PROPERTIES |
. art.properties. |
SOMEBITS |
, . , , x, , width height. |
FRAMEBITS |
, . x, , width, height . |
ALLBITS |
, . x, , width height . |
ERROR |
. . ABORT . |
ABORT |
. . ERROR , . |
, ImageObserver ( progress) :
/* <title>ObservedImageLoad</title>
* <applet code="ObservedImageLoad" width=290 height=140>
* <param name="img" value="mupk.gif">
* </applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
public class ObservedImageLoad extends Applet
implements Runnable, ImageObserver {
Image art;
Dimension d;
int progress;
Thread motor;
boolean loaded;
public void init() {
art = getImage(getDocumentBase(), getParameter("img"));
loaded = false;
progress = 0;
}
public void paint(Graphics g) {
d = this.getSize();
loaded = g.drawImage(art, 0, 0, this);
}
public boolean imageUpdate(Image img, int info,
int x, int y, int width, int height) {
if((info & ALLBITS) != 1) {
if(progress<d.height) {
progress = progress + height;
}
System.out.println(progress + "/" + d.height);
return true;
}
else {
return false;
} }
public void start() {
motor = new Thread(this);
motor. start();
}
public void stop() {
motor.stop();
}
public void run() {
motor.setPriority(Thread.MIN_PRIORITY);
while(!loaded) { // update progress indicator (5 fps)
repaint();
try {
motor.sleep(200);
}
catch(InterruptedException e) {}
}
} }
imageUpdate . info, ALLBITS. , heihgt . . run ( 200 ) , art . , , ObservedImageLoad.html.
MediaTracker
MediaTracker , . , , . MediaTracker addImage . MediaTracker . , , , .
ImageProducer
ImageProducer , Image. , ImageProducer, , . MemoryImageSource, ImageProducer. Image , ImageProducer.
MemorylmageSource
MemoryImageSource , . , MemoryImageSource:
MemoryImageSource(int width, int height, int pixel[], int offset, int scanLineWidth)
MemoryImageSource pixel[] RGB Image. Alpha, Red, Green Blue (OxAARRGGBB). Alpha .
MemoryImageSource ImageProducer, createImage , . MemoryImageSource, ( ) Gerard J.Holzmann Beyond Photography, The Digital Darkroom.
/* <title>Memory Image Generator</title>
* <applet code="MemoryImager" width=256 height=256>
* </applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
public class MemoryImager extends Applet {
Image art;
Dimension d;
public void init() {
generateImage();
}
public void generateImage() {
int pixels[] = new int[d.width * d.height];
int i = 0;
int r, g, b;
for(int y=0; y<h; y++) {
for(int x=0; x<h; x++) {
r = (x^y)&0xff; // red is x XOR
g = (x*2^y*2)&0xff; //green is 2x XOR 2y
b = (x*4^y*4)&0xff; // blue is 4x XOR 4y
pixels[i++] = (255 << 24) | (r << 16) | (g << 8) | b;
} }
art = createImage(new MemoryImageSource(d.width, d.height, pixels, 0, d.width));
}
public void paint(Graphics g) {
g.drawlmage(art, 0, 0, this);
} }
ImageFilter ImageFilterSource
ImageFilter ImageFilterSource . java.awt.image .
CropImageFilter
CropImageFilter . , . 2 , 40 . , CropImageFilter Java-.
RGBImageFilter
RGBImageFilter , , .
-
Java - . Java . , .
10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _. 10.11.2021 - 12:36: - Conscience -> . ? - _. 10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _. 10.11.2021 - 12:35: - Ecology -> - _. 10.11.2021 - 12:34: , - War, Politics and Science -> - _. 10.11.2021 - 12:34: , - War, Politics and Science -> . - _. 10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _. 10.11.2021 - 09:18: - New Technologies -> , 5G- - _. 10.11.2021 - 09:18: - Ecology -> - _. 10.11.2021 - 09:16: - Ecology -> - _. 10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _. 10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _. |