protected final int getSourceWidth(int targetWidth) { return levelImageSupport.getSourceWidth(targetWidth); }
public final int getSourceX(int tx) { return getSourceCoord(tx, 0, getSourceWidth() - 1); }
public final int getSourceWidth(int destWidth) { return double2int(getScale() * destWidth, 1, getSourceWidth()); }
@Test public void testGetSourceWidth() { final int w = levelImageSupport.getSourceWidth(); assertEquals(760, w); assertEquals(1, levelImageSupport.getSourceWidth(0)); assertEquals(1, levelImageSupport.getSourceWidth(1)); assertEquals(w - 1, levelImageSupport.getSourceWidth(w - 1)); assertEquals(w, levelImageSupport.getSourceWidth(w)); assertEquals(w, levelImageSupport.getSourceWidth(w + 1)); }
@Test public void testGetSourceWidth_sizeOdd() { final LevelImageSupport levelImageSupport = createLevelSupport(955); assertEquals(1, levelImageSupport.getSourceWidth(0)); assertEquals(8, levelImageSupport.getSourceWidth(1)); assertEquals(952, levelImageSupport.getSourceWidth(119)); assertEquals(955, levelImageSupport.getSourceWidth(120)); assertEquals(955, levelImageSupport.getSourceWidth(130)); }
@Test public void testGetSourceWidth_sizeEven() { final LevelImageSupport levelImageSupport = createLevelSupport(1000); assertEquals(1, levelImageSupport.getSourceWidth(0)); assertEquals(8, levelImageSupport.getSourceWidth(1)); assertEquals(1000, levelImageSupport.getSourceWidth(125)); assertEquals(1000, levelImageSupport.getSourceWidth(130)); }
@Test public void testGetSourceWidth_sizePowerOf2() { final LevelImageSupport levelImageSupport = createLevelSupport(1024); assertEquals(1, levelImageSupport.getSourceWidth(0)); assertEquals(8, levelImageSupport.getSourceWidth(1)); assertEquals(1024, levelImageSupport.getSourceWidth(128)); }
@Test public void testGetSourceX() { final int w = levelImageSupport.getSourceWidth(); assertEquals(760, w); assertEquals(0, levelImageSupport.getSourceX(0)); assertEquals(1, levelImageSupport.getSourceX(1)); assertEquals(w - 1, levelImageSupport.getSourceX(w - 1)); assertEquals(w - 1, levelImageSupport.getSourceX(w)); assertEquals(w - 1, levelImageSupport.getSourceX(w + 1)); }