comparison src/samer/maths/IteratorImageSource.java @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bf79fb79ee13
1 /*
2 * IteratorImageSource.java
3 *
4 * Copyright (c) 2000, Samer Abdallah, King's College London.
5 * All rights reserved.
6 *
7 * This software is provided AS iS and WITHOUT ANY WARRANTY;
8 * without even the implied warranty of MERCHANTABILITY or
9 * FITNESS FOR A PARTICULAR PURPOSE.
10 */
11
12 package samer.maths;
13 import samer.tools.*;
14 import java.awt.image.*;
15
16 /**
17 This is an image source that gets its values
18 from a Vec (vector) via its Vec.Iterator - ie,
19 it does not need access to an array of value
20 */
21
22 public class IteratorImageSource extends ImageSourceBase
23 {
24 Vec vec;
25 byte [] buf;
26
27 public IteratorImageSource( Vec v) { this( v, v.size(), 1); }
28 public IteratorImageSource( Vec v, int w, int h)
29 {
30 vec = v;
31 width = w;
32 height = h;
33 buf = new byte[v.size()];
34 }
35
36
37 protected int getHints() {
38 return ImageConsumer.TOPDOWNLEFTRIGHT
39 | ImageConsumer.COMPLETESCANLINES
40 | ImageConsumer.SINGLEPASS;
41 }
42
43 protected void sendPixels(ImageConsumer ic)
44 {
45 Vec.Iterator it=vec.iterator();
46
47 for (int i=0; it.more(); i++) {
48 buf[i] = (byte)map.clipInt(it.next());
49 }
50 ic.setPixels(0, 0, width, height, model, buf, 0, width);
51 }
52 }
53