001 /* 002 * MemoryGray16Image 003 * 004 * Copyright (c) 2003 Marco Schmidt. 005 * All rights reserved. 006 */ 007 008 package net.sourceforge.jiu.data; 009 010 import net.sourceforge.jiu.data.Gray16Image; 011 import net.sourceforge.jiu.data.MemoryShortChannelImage; 012 import net.sourceforge.jiu.data.PixelImage; 013 014 /** 015 * An implementation of {@link Gray16Image} that keeps the complete image in memory. 016 * This class inherits most of its functionality from its parent class 017 * {@link MemoryShortChannelImage}, using one <code>short</code> channel. 018 * @since 0.11.0 019 * @author Marco Schmidt 020 */ 021 public class MemoryGray16Image extends MemoryShortChannelImage implements Gray16Image 022 { 023 /** 024 * Creates a new MemoryGray16Image object with the specified resolution. 025 * Simply gives <code>1</code> (for one channel) and the two resolution arguments 026 * to the super constructor (of the parent class {@link MemoryShortChannelImage}). 027 * @param width the horizontal resolution, must be larger than zero 028 * @param height the vertical resolution, must be larger than zero 029 */ 030 public MemoryGray16Image(int width, int height) 031 { 032 super(1, width, height); 033 } 034 035 public PixelImage createCompatibleImage(int width, int height) 036 { 037 return new MemoryGray16Image(width, height); 038 } 039 040 public Class getImageType() 041 { 042 return Gray16Image.class; 043 } 044 045 public boolean isBlack(int x, int y) 046 { 047 return getShortSample(x, y) == 0; 048 } 049 050 public boolean isWhite(int x, int y) 051 { 052 return getShortSample(x, y) == (short)65535; 053 } 054 055 public void putBlack(int x, int y) 056 { 057 putSample(x, y, 0); 058 } 059 060 public void putWhite(int x, int y) 061 { 062 putSample(x, y, 65535); 063 } 064 }