Newer
Older
* This file is part of VisiCut. Copyright (C) 2012 Thomas Oster
Thomas Oster
committed
* <thomas.oster@rwth-aachen.de> RWTH Aachen University - 52062 Aachen, Germany
*
* VisiCut is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* VisiCut 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with VisiCut. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.t_oster.liblasercut;
import com.t_oster.liblasercut.platform.Point;
import java.util.LinkedList;
/**
*
* @author Thomas Oster <thomas.oster@rwth-aachen.de>
*/
Thomas Oster
committed
public class Raster3dPart extends JobPart
{
private GreyscaleRaster image = null;
private LaserProperty property = null;
Thomas Oster
committed
protected Point start = null;
private double resolution = 500;
Thomas Oster
committed
public Raster3dPart(GreyscaleRaster image, LaserProperty laserProperty, Point offset, double resolution)
Thomas Oster
committed
{
this.resolution = resolution;
this.property = laserProperty;
this.start = offset;
Thomas Oster
committed
}
@Override
public double getDPI()
{
return resolution;
}
Thomas Oster
committed
Thomas Oster
committed
@Override
public int getMinX()
{
Thomas Oster
committed
}
@Override
public int getMaxX()
{
return start.x+image.getWidth();
Thomas Oster
committed
}
@Override
public int getMinY()
{
Thomas Oster
committed
}
Thomas Oster
committed
Thomas Oster
committed
@Override
public int getMaxY()
{
return start.y + image.getHeight();
Thomas Oster
committed
}
/**
* Returns the upper left point of the given raster
*
* @param raster the raster which upper left corner is to determine
* @return
*/
public Point getRasterStart()
Thomas Oster
committed
{
Thomas Oster
committed
}
/**
* Returns one line of the given rasterpart every byte represents one pixel
* and the value corresponds to the raster power
*
* @param raster
* @param line
* @return
*/
public List<Byte> getRasterLine(int line)
Thomas Oster
committed
{
List<Byte> result = new LinkedList<Byte>();
for (int x = 0; x < image.getWidth(); x++)
Thomas Oster
committed
{
//TOTEST: Black white (byte converssion)
result.add((byte) image.getGreyScale(x, line));
Thomas Oster
committed
}
return result;
}
public int getRasterWidth()
Thomas Oster
committed
{
return this.image.getWidth();
Thomas Oster
committed
}
public int getRasterHeight()
Thomas Oster
committed
{
return this.image.getHeight();
Thomas Oster
committed
}
public LaserProperty getLaserProperty()
Thomas Oster
committed
{
return this.property;
Thomas Oster
committed
}
public List<Byte> getInvertedRasterLine(int line)
Thomas Oster
committed
{
List<Byte> result = new LinkedList<Byte>();
for (int x = 0; x < image.getWidth(); x++)
Thomas Oster
committed
{
//TOTEST: Black white (byte converssion)
result.add((byte) (255 - image.getGreyScale(x, line)));
Thomas Oster
committed
}
return result;
}