Ignore:
Timestamp:
08/07/19 14:14:42 (5 years ago)
Author:
bln4
Message:

New piping and functionality implementation to support the encrypting of images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Picture.java

    r1426 r1427  
    3737import org.expeditee.core.bounds.AxisAlignedBoxBounds;
    3838import org.expeditee.core.bounds.PolygonBounds;
     39import org.expeditee.encryption.core.EncryptedImage;
     40import org.expeditee.encryption.items.surrogates.Label;
     41import org.expeditee.encryption.items.surrogates.Label.LabelResult;
    3942import org.expeditee.gio.EcosystemManager;
    4043import org.expeditee.gio.GraphicsManager;
     
    4245import org.expeditee.gui.FrameIO;
    4346import org.expeditee.gui.FrameUtils;
     47import org.expeditee.gui.MessageBay;
    4448
    4549/**
     
    6266public class Picture extends XRayable {
    6367       
    64         public static final String REDACTED_IMAGE_NAME = "redacted.png";
     68        public static final String REDACTED_IMAGE_NAME = "expeditee_noise.encrypted";
    6569       
    6670        private static final float CROPPING_COMPOSITE_ALPHA = 0.5f;
     
    775779        @Override
    776780        public boolean refresh() {
    777                 // ImageIcon is faster, but cannot handle some formats
    778                 // (notably.bmp) hence, we try this first, then if it fails we try
    779                 // ImageIO
    780                 /*
    781                 try {
    782                         _image = new ImageIcon(_path).getImage();
    783                 } catch (Exception e) {
    784                 }
    785 
    786                 // if ImageIcon failed to read the image
    787                 if (_image == null || _image.getWidth() <= 0) {
    788                         try {
    789                                 _image = ImageIO.read(new File(_path));
    790                         } catch (IOException e) {
    791                                 // e.printStackTrace();
    792                                 Logger.Log(e);
    793                                 _image = null;
    794                                 return false;
    795                         }
    796                 }
    797 */
    798                
    799781                if (isNoise()) {
    800                         _image = Image.getNoise();
     782                        _image = EncryptedImage.getNoise();
    801783                } else {
    802                         _image = Image.getImage(_path);
     784                        String encryptionLabel = _source.getEncryptionLabel();
     785                        if (encryptionLabel == null || encryptionLabel.isEmpty()) {
     786                                _image = Image.getImage(_path);
     787                        } else {
     788                                LabelResult result = Label.getLabel(encryptionLabel);
     789                                if (result == LabelResult.SuccessResolveLabelToKey) {
     790                                        _image = EncryptedImage.getImage(_path, result.key);
     791                                } else {
     792                                        MessageBay.displayMessage(result.toString());
     793                                        _image = EncryptedImage.getNoise();
     794                                }
     795                        }
    803796                }
    804797               
Note: See TracChangeset for help on using the changeset viewer.