Skip to content
Snippets Groups Projects
RasterPart.java 2.72 KiB
Newer Older
  • Learn to ignore specific revisions
  • Thomas Oster's avatar
    Thomas Oster committed
    /**
     * This file is part of VisiCut.
    
     * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de>
    
    Thomas Oster's avatar
    Thomas Oster committed
     * RWTH Aachen University - 52062 Aachen, Germany
    
    Thomas Oster's avatar
    Thomas Oster committed
     *     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.
    
    Thomas Oster's avatar
    Thomas Oster committed
     *    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.
    
    Thomas Oster's avatar
    Thomas Oster committed
     *     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;
    
    Thomas Oster's avatar
    Thomas Oster committed
    import java.util.List;
    
    Thomas Oster's avatar
    Thomas Oster committed
    
    /**
     *
     * @author Thomas Oster <thomas.oster@rwth-aachen.de>
     */
    
      BlackWhiteRaster image = null;
      LaserProperty property = null;
      Point start = null;
    
      double resolution = 500;
    
      public RasterPart(BlackWhiteRaster image, LaserProperty laserProperty, Point offset, double resolution)
    
        this.image = image;
        this.property = laserProperty;
        this.start = offset;
    
        this.resolution = resolution;
    
      @Override
      public double getDPI()
      {
          return resolution;
      }
    
        return this.start.x;
    
        return this.start.x + this.image.getWidth();
    
        return start.y+image.getHeight();
    
    Thomas Oster's avatar
    Thomas Oster committed
      }
    
      /**
       * Returns the upper left point of the given raster
       * @param raster the raster which upper left corner is to determine
    
    Thomas Oster's avatar
    Thomas Oster committed
       */
    
      public Point getRasterStart()
    
    Thomas Oster's avatar
    Thomas Oster committed
      }
    
      /**
       * Returns one line of the given rasterpart
       * every byte represents 8 pixel and the value corresponds to
       * 1 when black or 0 when white
       * @param raster
       * @param line
    
    Thomas Oster's avatar
    Thomas Oster committed
       */
    
      public List<Byte> getRasterLine(int line)
    
    Thomas Oster's avatar
    Thomas Oster committed
      {
        List<Byte> result = new LinkedList<Byte>();
    
        for (int x = 0; x < (image.getWidth() + 7) / 8; x++)
    
          result.add(image.getByte(x, line));
    
    Thomas Oster's avatar
    Thomas Oster committed
        }
        return result;
      }
    
    
      public boolean isBlack(int x, int y)
    
        return this.image.isBlack(x, y);
    
      public int getRasterWidth()
    
        return this.image.getWidth();
    
      public int getRasterHeight()
    
        return this.image.getHeight();
    
      public LaserProperty getLaserProperty()
    
          return this.property;