Changeset 11647
- Timestamp:
- 2006-04-12T09:31:03+12:00 (18 years ago)
- Location:
- trunk/gsdl/src/java/org/nzdl/gsdl/GsdlCollageApplet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/java/org/nzdl/gsdl/GsdlCollageApplet/CollageImage.java
r6816 r11647 4 4 import java.awt.geom.*; 5 5 import java.io.*; 6 import java.net.*; 6 7 7 8 /** … … 29 30 /** Indicates whether or not the image has been drawn on the applet previously */ 30 31 boolean fresh = true; 31 32 33 URL url_ = null; 34 32 35 /** Reflects the translation of the image from the origin to its position on the screen */ 33 36 AffineTransform af_ = null; … … 46 49 * @param from_url The source url for the image 47 50 * @param name The file name of the image */ 48 public CollageImage(Image image, String from_url, String name)51 public CollageImage(Image image, URL url, String from_url, String name) 49 52 { 50 53 image_ = image; 51 54 from_url_ = from_url; 55 url_ = url; 52 56 name_ = name; 53 57 } -
trunk/gsdl/src/java/org/nzdl/gsdl/GsdlCollageApplet/DownloadImages.java
r11564 r11647 24 24 25 25 Image image_; 26 String url _;26 String urlString_; 27 27 String name_; 28 URL url_; 28 29 29 30 /** Constructs a downloaded image structure from the given parameters … … 31 32 * @param url the source url for this image 32 33 * @param name the name of the image file */ 33 public ImageUrlTriple (Image image, String url, String name)34 public ImageUrlTriple (Image image, URL url, String urlString, String name) 34 35 { 35 36 image_ = image; 36 37 url_ = url; 38 urlString_ = urlString; 37 39 name_ = name; 38 40 } … … 42 44 } 43 45 44 String url () {45 return url _;46 String urlString() { 47 return urlString_; 46 48 } 47 49 … … 50 52 } 51 53 52 } 53 54 URL url(){ 55 return url_; 56 } 57 58 } 54 59 55 60 … … 62 67 int num_of_downloads; 63 68 boolean stopDownload; 64 69 65 70 66 71 … … 92 97 93 98 } 99 94 100 Image image = Toolkit.getDefaultToolkit().getImage(url); 95 101 96 97 98 102 tracker.addImage(image,num_of_downloads); 103 104 try{ 99 105 System.out.println( " downloading ..."); 100 106 tracker.waitForID(num_of_downloads); 101 107 System.out.println(Thread.currentThread().getName() + " get!!!"); 102 108 } … … 105 111 } 106 112 107 downloaded_image = new ImageUrlTriple(image,url String,name);113 downloaded_image = new ImageUrlTriple(image,url,urlString,name); 108 114 num_of_downloads++; 109 115 … … 131 137 } 132 138 catch(InterruptedException e){ 139 //e.printStackTrace(); 133 140 return null; 134 141 } … … 150 157 private CollageImage process(ImageUrlTriple iutriple){ 151 158 Image image = iutriple.image(); 152 String from_url = iutriple.url ();159 String from_url = iutriple.urlString(); 153 160 String img_name = iutriple.name(); 154 155 CollageImage collage_image = new CollageImage(image,from_url,img_name); 161 URL url = iutriple.url(); 162 163 CollageImage collage_image = new CollageImage(image,url,from_url,img_name); 156 164 157 165 image = collage_image.image_; … … 195 203 // declare an array to hold the pixels 196 204 int[] pixels = new int[w * h]; 197 205 198 206 // get the pixels of the image into the pixels array 199 207 PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w); 200 208 201 209 try { 202 210 System.err.println(" grab pixels...."); 203 211 pg.grabPixels(); 204 System.err.println(" got pixels !!!");212 System.err.println(" got pixels"); 205 213 } catch (InterruptedException e) { 206 214 System.err.println("interrupted waiting for pixels!"); … … 216 224 217 225 // loop through every pixel in the picture and handle it 218 for (int j = 0; j < h; j++) { 219 for (int i = 0; i < w; i++) { 220 pixels[j * w + i] |= (255 << 24) & 0xff000000; 221 } 222 } 223 224 // set the pixels of the whole picture to the pixels array 225 pg.setPixels(0, 0, w, h, pg.getColorModel(), pixels, 0, w); 226 227 // create the new image and return it 228 return( app_.createImage(new MemoryImageSource(w, h, pixels, 0, w)) ); 229 226 for (int j = 0; j < h; j++) { 227 for (int i = 0; i < w; i++) { 228 pixels[j * w + i] |= (255 << 24) & 0xff000000; 229 } 230 } 231 232 // set the pixels of the whole picture to the pixels array 233 pg.setPixels(0, 0, w, h, pg.getColorModel(), pixels, 0, w); 234 // create the new image and return it 235 return( app_.createImage(new MemoryImageSource(w, h, pixels, 0, w)) ); 236 237 238 239 230 240 } 231 241
Note:
See TracChangeset
for help on using the changeset viewer.