Ignore:
Timestamp:
07/31/19 15:51:04 (5 years ago)
Author:
bln4
Message:

Implemented surrogates for images. When you add an encryption label to a picture, the default is a on-the-fly generated image of noise. This generated image has the same size specifications as the primary image.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gio/ImageManager.java

    r1097 r1426  
    55import java.net.HttpURLConnection;
    66import java.net.URL;
     7import java.util.Random;
    78
    89import org.expeditee.core.Colour;
     
    7576        public abstract Image getImage(String filename);
    7677       
     78        /** Gets an image that is just noise */
     79        public Image getNoise() {
     80                int width = 100;
     81                int height = 100;
     82                int[] pixelData = new int[width * height];
     83                Random rand = new Random();
     84               
     85                for (int i = 0; i < pixelData.length; i++) {
     86                        int alpha = rand.nextInt(256) << 24;
     87                        int red = rand.nextInt(256) << 16;
     88                        int green = rand.nextInt(256) << 8;
     89                        int blue = rand.nextInt(256);
     90                        pixelData[i] = alpha | red | green | blue;
     91                }
     92               
     93                return createImage(width, height, pixelData);
     94        }
     95       
    7796        /** Gets image data from a HTTP connection. */
    7897        public abstract Image getImage(HttpURLConnection connection) throws IOException;
     
    125144       
    126145        /** Writes the image data to disk. Format should be png, bmp, etc. */
    127         public abstract boolean writeImageToDisk(Image image, String format, File file) throws IOException;
    128        
     146        public abstract boolean writeImageToDisk(Image image, String format, File file) throws IOException;     
    129147}
Note: See TracChangeset for help on using the changeset viewer.