Beispiel #1
0
 public ImageIcon getPhoto() throws Exception {
   if (photo == null) {
     org.cagrid.demo.photosharing.domain.Image image = gallery.getClient().getImage(des);
     byte[] imageData = Base64Decoder.decode(image.getData());
     photo = new ImageIcon(Toolkit.getDefaultToolkit().createImage(imageData));
   }
   return photo;
 }
Beispiel #2
0
  public void addPhoto(String imageName, String imageDescription, File f) throws Exception {

    byte[] imageBytes = ImageUtils.loadImageAsBytes(f.getAbsolutePath());
    // Note: only the castor Base64Encoder encodes
    // properly... the Sun one doesn't (corrupts image)
    String encoded = new String(Base64Encoder.encode(imageBytes));

    org.cagrid.demo.photosharing.domain.ImageDescription beanDesc =
        new org.cagrid.demo.photosharing.domain.ImageDescription();
    beanDesc.setId(Long.valueOf(0)); // doesn't matter what
    // this is set to
    beanDesc.setDescription(imageDescription);
    beanDesc.setName(imageName);
    beanDesc.setType(ImageFileFilter.getExtension(f));

    org.cagrid.demo.photosharing.domain.Image beanImage =
        new org.cagrid.demo.photosharing.domain.Image();
    beanImage.setId(Long.valueOf(0)); // doesn't matter what
    // this is set to

    beanImage.setImageDescription(beanDesc);
    beanImage.setData(encoded);
    getClient().addImage(beanImage);
  }