annotate src/samer/tools/ArrayImageSource.java @ 3:15b93db27c04
Get StreamSource to compile, update args for demo
author |
samer |
date |
Fri, 05 Apr 2019 17:00:18 +0100 |
parents |
bf79fb79ee13 |
children |
|
rev |
line source |
samer@0
|
1 /*
|
samer@0
|
2 * Copyright (c) 2000, Samer Abdallah, King's College London.
|
samer@0
|
3 * All rights reserved.
|
samer@0
|
4 *
|
samer@0
|
5 * This software is provided AS iS and WITHOUT ANY WARRANTY;
|
samer@0
|
6 * without even the implied warranty of MERCHANTABILITY or
|
samer@0
|
7 * FITNESS FOR A PARTICULAR PURPOSE.
|
samer@0
|
8 */
|
samer@0
|
9
|
samer@0
|
10 package samer.tools;
|
samer@0
|
11 import java.awt.image.*;
|
samer@0
|
12
|
samer@0
|
13 public class ArrayImageSource extends ImageSourceBase
|
samer@0
|
14 {
|
samer@0
|
15 double array[];
|
samer@0
|
16 byte buf[];
|
samer@0
|
17
|
samer@0
|
18 public ArrayImageSource( double A[]) { this(A,A.length,1); }
|
samer@0
|
19 public ArrayImageSource( double A[], boolean vertical) { this(A,1,A.length); }
|
samer@0
|
20 public ArrayImageSource( double A[], int w, int h)
|
samer@0
|
21 {
|
samer@0
|
22 array = A;
|
samer@0
|
23 width = w;
|
samer@0
|
24 height = h;
|
samer@0
|
25 buf = new byte[A.length];
|
samer@0
|
26 }
|
samer@0
|
27
|
samer@0
|
28 protected int getHints() {
|
samer@0
|
29 return ImageConsumer.TOPDOWNLEFTRIGHT
|
samer@0
|
30 | ImageConsumer.COMPLETESCANLINES
|
samer@0
|
31 | ImageConsumer.SINGLEPASS;
|
samer@0
|
32 }
|
samer@0
|
33
|
samer@0
|
34 protected void sendPixels(ImageConsumer ic)
|
samer@0
|
35 {
|
samer@0
|
36 int i;
|
samer@0
|
37 for (i=0; i<array.length; i++) {
|
samer@0
|
38 buf[i] = (byte)map.clipInt(array[i]);
|
samer@0
|
39 }
|
samer@0
|
40 ic.setPixels(0, 0, width, height, model, buf, 0, width);
|
samer@0
|
41 }
|
samer@0
|
42 }
|