| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| <<<<<<< HEAD |
| * Pierre Allard - initial API and implementation |
| * Regent L'Archeveque |
| * |
| ======= |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| >>>>>>> refs/heads/eclipse_pa |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.images.converters; |
| |
| import org.eclipse.apogy.common.converters.IConverter; |
| import org.eclipse.apogy.common.images.EImage; |
| import org.eclipse.apogy.common.images.EImagesUtilities; |
| import org.eclipse.swt.graphics.ImageData; |
| |
| public class ObjectToImageDataConverter implements IConverter { |
| |
| public ObjectToImageDataConverter() { |
| } |
| |
| @Override |
| public Class<?> getOutputType() { |
| return ImageData.class; |
| } |
| |
| @Override |
| public Class<?> getInputType() { |
| return EImage.class; |
| } |
| |
| @Override |
| public boolean canConvert(Object input) { |
| if (input instanceof EImage) { |
| EImage img = (EImage) input; |
| return img.getImageContent() != null; |
| } else { |
| return false; |
| } |
| } |
| |
| @Override |
| public Object convert(Object input) throws Exception { |
| EImage img = (EImage) input; |
| return EImagesUtilities.INSTANCE.convertToImageData(img.getImageContent()); |
| } |
| } |