Java tutorial
/******************************************************************************* * * Copyright (C) 2015 Mytech Ingenieria Aplicada <http://www.mytechia.com> * Copyright (C) 2015 Gervasio Varela <gervarela@picandocodigo.com> * * This file is part of Dandelion. * * Dandelion is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Dandelion is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Dandelion. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package com.hi3project.dandelion.util.properties; import org.apache.commons.codec.binary.Base64; /** * * @author Gervasio Varela Fernandez - Integrated Group for Engineering Research * @version 1 * * Changelog: * 29-ene-2015 */ public class ImageProperty extends Property { /** The data of the image is stored enconded as a string * in base64 * * @param label the label of the image property * @param imageData raw data of the PNG image */ public ImageProperty(String label, byte[] imageData) { super(PropertyType.imageProperty, label, null); setValue(encondeImage(imageData)); } public ImageProperty(String label, String data) { super(PropertyType.imageProperty, label, data); } public byte[] getImageData() { return decodeImage(this.getValue()); } private String encondeImage(byte[] imageData) { return new String(Base64.encodeBase64(imageData)); } private byte[] decodeImage(String imageData) { return Base64.decodeBase64(imageData.getBytes()); } }