JavaTM Platform
Standard Ed. 6

java.awt.image
클래스 MemoryImageSource

java.lang.Object 
  상위를 확장 java.awt.image.MemoryImageSource
모든 구현된 인터페이스:
ImageProducer


public class MemoryImageSource
extends Object
implements ImageProducer

이 클래스는, 배열을 사용해 Image 의 픽셀치를 생성하는 ImageProducer 인터페이스를 구현합니다. 이하의 예는, X 축방향으로 흑으로부터 파랑에 변화해, Y 축방향으로 흑으로부터 빨강에 변화하는 100×100 의 이미지입니다.

 
        int w = 100;
        int h = 100;
        int pix[] = new int[w * h];
        int index = 0;
        for (int y = 0; y < h; y++) {
            int red = (y * 255) / (h - 1);
            for (int x = 0; x < w; x++) {
                int blue = (x * 255) / (w - 1);
                pix[index++] = (255 << 24) | (red << 16) | blue;
            }
        }
        Image img = createImage(new MemoryImageSource(w, h, pix, 0, w));
 
 
또, MemoryImageSource 는, 시간과 함께 변화해, 애니메이션이나 커스텀 렌더링을 가능하게 하는 메모리 이미지를 관리하는 기능을 가집니다. 다음에, 애니메이션 소스, 및 데이터의 신호 변화의 설정 방법법의 예를 나타냅니다 (Garth Dickie 에 의한 MemoryAnimationSourceDemo 로부터의 적용).

        int pixels[];
        MemoryImageSource source;

        public void init() {
            int width = 50;
            int height = 50;
            int size = width * height;
            pixels = new int[size];

            int value = getBackground(). getRGB();
            for (int i = 0; i < size; i++) {
                pixels[i] = value;
            }

            source = new MemoryImageSource(width, height, pixels, 0, width);
            source.setAnimated(true);
            image = createImage(source);
        }

        public void run() {
            Thread me = Thread.currentThread( );
            me.setPriority(Thread.MIN_PRIORITY);

            while (true) {
                try {
                        thread.sleep(10);
                } catch (InterruptedException e) {
                            return;
                }

                // Modify the values in the pixels array at (x, y, w, h)

                // Send the new data to the interested ImageConsumers
                source.newPixels(x, y, w, h);
            }
        }

 

관련 항목:
ImageProducer

생성자 의 개요
MemoryImageSource (int w, int h, ColorModel  cm, byte[] pix, int off, int scan)
          byte 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.
MemoryImageSource (int w, int h, ColorModel  cm, byte[] pix, int off, int scan, Hashtable <?,?> props)
          byte 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.
MemoryImageSource (int w, int h, ColorModel  cm, int[] pix, int off, int scan)
          정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.
MemoryImageSource (int w, int h, ColorModel  cm, int[] pix, int off, int scan, Hashtable <?,?> props)
          정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.
MemoryImageSource (int w, int h, int[] pix, int off, int scan)
          디폴트 RGB 칼라 모델의 정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.
MemoryImageSource (int w, int h, int[] pix, int off, int scan, Hashtable <?,?> props)
          디폴트 RGB 칼라 모델의 정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.
 
메소드의 개요
 void addConsumer (ImageConsumer  ic)
          이 이미지의 데이터의 전달 대상이 되고 있는 컨슈머(consumer)의 리스트에 ImageConsumer 를 추가합니다.
 boolean isConsumer (ImageConsumer  ic)
          현재 이 이미지의 데이터의 전달 대상이 되고 있는 컨슈머(consumer)의 리스트에 ImageConsumer 가 있을지 어떨지를 판정합니다.
 void newPixels ()
          이 이미지 데이터를 현재 요구하는 ImageConsumer 에 픽셀의 새로운 버퍼 전체를 송출해, 애니메이션 프레임의 송출이 완료한 것을 통지합니다.
 void newPixels (byte[] newpix, ColorModel  newmodel, int offset, int scansize)
          새로운 byte 배열을, 이 이미지의 픽셀을 보관 유지하도록(듯이) 변경합니다.
 void newPixels (int[] newpix, ColorModel  newmodel, int offset, int scansize)
          새로운 int 배열을, 이 이미지의 픽셀을 보관 유지하도록(듯이) 변경합니다.
 void newPixels (int x, int y, int w, int h)
          이 이미지의 데이터를 현재 요구하는 ImageConsumer 에 픽셀의 구형 영역 버퍼를 송출해, 애니메이션 프레임의 송출이 완료한 것을 통지합니다.
 void newPixels (int x, int y, int w, int h, boolean framenotify)
          이 이미지의 데이터를 현재 요구하는 ImageConsumer 에, 픽셀의 구형 영역 버퍼를 송출합니다.
 void removeConsumer (ImageConsumer  ic)
          이 이미지의 데이터의 전달 대상이 되고 있는 컨슈머(consumer)의 리스트로부터 ImageConsumer 를 삭제합니다.
 void requestTopDownLeftRightResend (ImageConsumer  ic)
          지정된 ImageConsumer 에, 위에서 아래, 왼쪽에서 오른쪽의 순서로 이제(벌써) 1 회 이미지 데이터를 다시 전달하도록(듯이) 요구합니다.
 void setAnimated (boolean animated)
          animated 파라미터에 따라, 이 메모리 이미지를 멀티 프레임의 애니메이션 또는 싱글 프레임의 정지 이미지로 변경합니다.
 void setFullBufferUpdates (boolean fullbuffers)
          변경이 있었을 때는 언제라도 픽셀의 완전한 버퍼를 송출해, 이 애니메이션화 메모리 이미지를 항상 갱신할지 어떨지를 지정합니다.
 void startProduction (ImageConsumer  ic)
          이 이미지 데이터를 요구하는 컨슈머(consumer)의 리스트에 ImageConsumer 를 추가해, ImageConsumer 인터페이스 경유로 즉시 이미지 데이터의 전송을 개시합니다.
 
클래스 java.lang. Object 로부터 상속된 메소드
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

생성자 의 상세

MemoryImageSource

public MemoryImageSource(int w,
                         int h,
                         ColorModel  cm,
                         byte[] pix,
                         int off,
                         int scan)
byte 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.

파라미터:
w - 구형 픽셀의 폭
h - 구형 픽셀의 높이
cm - 지정된 ColorModel
pix - 픽셀의 배열
off - 최초의 픽셀을 배열의 어디에 포함하는지를 나타낸다 오프셋(offset)
scan - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
관련 항목:
Component.createImage(java.awt.image.ImageProducer)

MemoryImageSource

public MemoryImageSource(int w,
                         int h,
                         ColorModel  cm,
                         byte[] pix,
                         int off,
                         int scan,
                         Hashtable <?,?> props)
byte 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.

파라미터:
w - 구형 픽셀의 폭
h - 구형 픽셀의 높이
cm - 지정된 ColorModel
pix - 픽셀의 배열
off - 최초의 픽셀을 배열의 어디에 포함하는지를 나타낸다 오프셋(offset)
scan - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
props - ImageProducer 가 이미지 처리로 사용한다 프로퍼티 리스트
관련 항목:
Component.createImage(java.awt.image.ImageProducer)

MemoryImageSource

public MemoryImageSource(int w,
                         int h,
                         ColorModel  cm,
                         int[] pix,
                         int off,
                         int scan)
정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.

파라미터:
w - 구형 픽셀의 폭
h - 구형 픽셀의 높이
cm - 지정된 ColorModel
pix - 픽셀의 배열
off - 최초의 픽셀을 배열의 어디에 포함하는지를 나타낸다 오프셋(offset)
scan - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
관련 항목:
Component.createImage(java.awt.image.ImageProducer)

MemoryImageSource

public MemoryImageSource(int w,
                         int h,
                         ColorModel  cm,
                         int[] pix,
                         int off,
                         int scan,
                         Hashtable <?,?> props)
정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.

파라미터:
w - 구형 픽셀의 폭
h - 구형 픽셀의 높이
cm - 지정된 ColorModel
pix - 픽셀의 배열
off - 최초의 픽셀을 배열의 어디에 포함하는지를 나타낸다 오프셋(offset)
scan - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
props - ImageProducer 가 이미지 처리로 사용한다 프로퍼티 리스트
관련 항목:
Component.createImage(java.awt.image.ImageProducer)

MemoryImageSource

public MemoryImageSource(int w,
                         int h,
                         int[] pix,
                         int off,
                         int scan)
디폴트 RGB 칼라 모델의 정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.

파라미터:
w - 구형 픽셀의 폭
h - 구형 픽셀의 높이
pix - 픽셀의 배열
off - 최초의 픽셀을 배열의 어디에 포함하는지를 나타낸다 오프셋(offset)
scan - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
관련 항목:
Component.createImage(java.awt.image.ImageProducer) , ColorModel.getRGBdefault()

MemoryImageSource

public MemoryImageSource(int w,
                         int h,
                         int[] pix,
                         int off,
                         int scan,
                         Hashtable <?,?> props)
디폴트 RGB 칼라 모델의 정수형 배열을 사용해 Image 객체 데이터를 생성하는 ImageProducer 객체를 구축합니다.

파라미터:
w - 구형 픽셀의 폭
h - 구형 픽셀의 높이
pix - 픽셀의 배열
off - 최초의 픽셀을 배열의 어디에 포함하는지를 나타낸다 오프셋(offset)
scan - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
props - ImageProducer 가 이미지 처리로 사용한다 프로퍼티 리스트
관련 항목:
Component.createImage(java.awt.image.ImageProducer) , ColorModel.getRGBdefault()
메소드의 상세

addConsumer

public void addConsumer(ImageConsumer  ic)
이 이미지의 데이터의 전달 대상이 되고 있는 컨슈머(consumer)의 리스트에 ImageConsumer 를 추가합니다.

정의:
인터페이스 ImageProducer 내의 addConsumer
파라미터:
ic - 지정된 ImageConsumer
예외:
NullPointerException - 지정되었다 ImageConsumer 가 null 의 경우
관련 항목:
ImageConsumer

isConsumer

public boolean isConsumer(ImageConsumer  ic)
현재 이 이미지의 데이터의 전달 대상이 되고 있는 컨슈머(consumer)의 리스트에 ImageConsumer 가 있을지 어떨지를 판정합니다.

정의:
인터페이스 ImageProducer 내의 isConsumer
파라미터:
ic - 지정된 ImageConsumer
반환값:
ImageConsumer 가 리스트에 있는 경우는 true, 그렇지 않은 경우는 false
관련 항목:
ImageConsumer

removeConsumer

public void removeConsumer(ImageConsumer  ic)
이 이미지의 데이터의 전달 대상이 되고 있는 컨슈머(consumer)의 리스트로부터 ImageConsumer 를 삭제합니다.

정의:
인터페이스 ImageProducer 내의 removeConsumer
파라미터:
ic - 지정된 ImageConsumer
관련 항목:
ImageConsumer

startProduction

public void startProduction(ImageConsumer  ic)
이 이미지 데이터를 요구하는 컨슈머(consumer)의 리스트에 ImageConsumer 를 추가해, ImageConsumer 인터페이스 경유로 즉시 이미지 데이터의 전송을 개시합니다.

정의:
인터페이스 ImageProducer 내의 startProduction
파라미터:
ic - ImageConsumer 인터페이스를 개입시킨, 지정된 ImageConsumer 이미지 데이터
관련 항목:
ImageConsumer

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(ImageConsumer  ic)
지정된 ImageConsumer 에, 위에서 아래, 왼쪽에서 오른쪽의 순서로 이제(벌써) 1 회 이미지 데이터를 다시 전달하도록(듯이) 요구합니다.

정의:
인터페이스 ImageProducer 내의 requestTopDownLeftRightResend
파라미터:
ic - 지정된 ImageConsumer
관련 항목:
ImageConsumer

setAnimated

public void setAnimated(boolean animated)
animated 파라미터에 따라, 이 메모리 이미지를 멀티 프레임의 애니메이션 또는 싱글 프레임의 정지 이미지로 변경합니다.  

이 메소드는, 모든 ImageConsumer 가 정상적인 멀티 프레임 데이터를 받는 것을 보증하기 위해서, MemoryImageSource 의 구축 후 즉시, 이미지가 생성되기 전에 호출할 필요가 있습니다. 이 플래그를 설정하기 전에, ImageConsumer 를 이 ImageProducer 에 추가하면(자), 접속했을 때에 이용 가능함 픽셀 데이터의 snapshot만이 ImageConsumer 로부터 참조됩니다.

파라미터:
animated - 그 이미지가 멀티 프레임 애니메이션의 경우는 true

setFullBufferUpdates

public void setFullBufferUpdates(boolean fullbuffers)
변경이 있었을 때는 언제라도 픽셀의 완전한 버퍼를 송출해, 이 애니메이션화 메모리 이미지를 항상 갱신할지 어떨지를 지정합니다. 이 플래그는, setAnimated() 메소드 경유로 애니메이션 플래그가 온이 되지 않는 경우는 무시됩니다.  

이 메소드는, MemoryImageSource 의 구축 후 즉시, 이미지가 작성되기 전에 불려 가 모든 ImageConsumer 에 정상적인 픽셀 전송 정보를 주고 받습니다.

파라미터:
fullbuffers - 완전한 픽셀 버퍼를 항상 송출하는 경우는 true
관련 항목:
setAnimated(boolean)

newPixels

public void newPixels()
이 이미지 데이터를 현재 요구하는 ImageConsumer 에 픽셀의 새로운 버퍼 전체를 송출해, 애니메이션 프레임의 송출이 완료한 것을 통지합니다. 이 메소드는, setAnimated() 메소드를 개입시켜, 애니메이션 플래그가 온이 되어 있는 경우에만 동작합니다.

관련 항목:
newPixels(int, int, int, int, boolean) , ImageConsumer , setAnimated(boolean)

newPixels

public void newPixels(int x,
                      int y,
                      int w,
                      int h)
이 이미지의 데이터를 현재 요구하는 ImageConsumer 에 픽셀의 구형 영역 버퍼를 송출해, 애니메이션 프레임의 송출이 완료한 것을 통지합니다. 이 메소드는, setAnimated() 메소드를 개입시켜, 애니메이션 플래그가 온이 되어 있는 경우에만 동작합니다. setFullBufferUpdates() 메소드로 완전 버퍼 갱신 플래그가 온이 되어 있는 경우, 구형 파라미터는 무시되어 전버퍼가 항상 송출됩니다.

파라미터:
x - 송출되는 픽셀의 구형의 좌상구석의 x 좌표
y - 송출되는 픽셀의 구형의 좌상구석의 y 좌표
w - 송출되는 픽셀의 구형의 폭
h - 송출되는 픽셀의 구형의 높이
관련 항목:
newPixels(int, int, int, int, boolean) , ImageConsumer , setAnimated(boolean) , setFullBufferUpdates(boolean)

newPixels

public void newPixels(int x,
                      int y,
                      int w,
                      int h,
                      boolean framenotify)
이 이미지의 데이터를 현재 요구하는 ImageConsumer 에, 픽셀의 구형 영역 버퍼를 송출합니다. framenotify 파라미터가 true 의 경우는, 애니메이션 프레임의 송출이 완료한 것도 통지합니다. 이 메소드는, setAnimated() 메소드를 개입시켜, 애니메이션 플래그가 온이 되어 있는 경우에만 동작합니다. setFullBufferUpdates() 메소드로 완전 버퍼 갱신 플래그가 온이 되어 있는 경우, 구형 파라미터는 무시되어 전버퍼가 항상 송출됩니다.

파라미터:
x - 송출되는 픽셀의 구형의 좌상구석의 x 좌표
y - 송출되는 픽셀의 구형의 좌상구석의 y 좌표
w - 송출되는 픽셀의 구형의 폭
h - 송출되는 픽셀의 구형의 높이
framenotify - 컨슈머(consumer)에게 SINGLEFRAMEDONE 통지를 송출하는 경우는 true
관련 항목:
ImageConsumer , setAnimated(boolean) , setFullBufferUpdates(boolean)

newPixels

public void newPixels(byte[] newpix,
                      ColorModel  newmodel,
                      int offset,
                      int scansize)
새로운 byte 배열을, 이 이미지의 픽셀을 보관 유지하도록(듯이) 변경합니다. setAnimated() 메소드 경유로 애니메이션 플래그가 온이 되어 있는 경우, 이 이미지의 데이터를 현재 요구하고 있는 ImageConsumer 에, 새로운 픽셀을 즉시 전송 합니다.

파라미터:
newpix - 새로운 픽셀 배열
newmodel - 지정된 ColorModel
offset - 배열에의 오프셋(offset)
scansize - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
관련 항목:
newPixels(int, int, int, int, boolean) , setAnimated(boolean)

newPixels

public void newPixels(int[] newpix,
                      ColorModel  newmodel,
                      int offset,
                      int scansize)
새로운 int 배열을, 이 이미지의 픽셀을 보관 유지하도록(듯이) 변경합니다. setAnimated() 메소드 경유로 애니메이션 플래그가 온이 되어 있는 경우, 이 이미지의 데이터를 현재 요구하고 있는 ImageConsumer 에, 새로운 픽셀을 즉시 전송 합니다.

파라미터:
newpix - 새로운 픽셀 배열
newmodel - 지정된 ColorModel
offset - 배열에의 오프셋(offset)
scansize - 배열내에서의 있는 픽셀행으로부터 다음의 픽셀행까지의 거리
관련 항목:
newPixels(int, int, int, int, boolean) , setAnimated(boolean)

JavaTM Platform
Standard Ed. 6

버그의 보고와 기능의 요청
한층 더 자세한 API 레퍼런스 및 개발자 문서에 대해서는,Java SE 개발자용 문서를 참조해 주세요. 개발자전용의 상세한 해설, 개념의 개요, 용어의 정의, 버그의 회피책, 및 코드 실례가 포함되어 있습니다.

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.