From: <doc...@us...> - 2007-06-07 05:12:43
|
Revision: 84 http://openpcl.svn.sourceforge.net/openpcl/?rev=84&view=rev Author: documentsystems Date: 2007-06-06 22:12:45 -0700 (Wed, 06 Jun 2007) Log Message: ----------- Howard Hoagland. Fixed bug where raster dot patterns on the screen look ok zoomed at 100% but as the image is zoomed smaller and smaller, the dot patterns look like checkerboard patterns because the dots get too close together. Added method omitSpecificPixelsByZoomFactor() and changed method drawRasterPixelsOnBitmap() to take away pixels in raster blocks. More pixels are taken away as the image is zoomed smaller. Modified Paths: -------------- openpcl/src/com/openpcl/pclrenderimage/render/PriRasterDrawing.java Modified: openpcl/src/com/openpcl/pclrenderimage/render/PriRasterDrawing.java =================================================================== --- openpcl/src/com/openpcl/pclrenderimage/render/PriRasterDrawing.java 2007-06-05 23:41:38 UTC (rev 83) +++ openpcl/src/com/openpcl/pclrenderimage/render/PriRasterDrawing.java 2007-06-07 05:12:45 UTC (rev 84) @@ -97,6 +97,12 @@ protected static final int sColorGreen = new Color (0,91,28).getRGB(); protected static final int sColorBlue = new Color (0,0,255).getRGB(); protected static final int sColorCyan = new Color (0,255,255).getRGB(); + + private int mOmitEveryNPixels = 0; + private int mOmitNPixelsThenDrawOne = 0; + private int mPixelsDrawnCounter = 0; + private int mPixelsOmittedCounter = 0; + private int mPixelStaggerRowBeginLocaction = 0; /** Constructor */ public PriRasterDrawing(PclRenderImage pPclRenderImage, BufferedImage pBufferedImageToDrawOn) { @@ -418,48 +424,116 @@ int offsetX = 0; int arrayLength = pUncompressedDataByteArray.length; double zoomPct = mPclRenderImage.getCurrentZoomFactor(); + + mOmitEveryNPixels = 0; + mOmitNPixelsThenDrawOne = 0; + + // Make the begin pixel be 0, 1, 2 ,3 every 4 rows so that the pixel drawing is staggered vertically every 4 rows + if (mPixelStaggerRowBeginLocaction < 4) { + mPixelsDrawnCounter = mPixelStaggerRowBeginLocaction; + mPixelsOmittedCounter = mPixelStaggerRowBeginLocaction; + mPixelStaggerRowBeginLocaction++; + } else { + mPixelsDrawnCounter = 0; + mPixelsOmittedCounter = 0; + mPixelStaggerRowBeginLocaction = 0; + } + + // Set the omit pixels 2 variables to omit every N pixels or to omit N pixels the draw one pixel + if (zoomPct >= .90d) { mOmitEveryNPixels = 0; + } else if (zoomPct >= .80d) { mOmitEveryNPixels = 0; + } else if (zoomPct >= .70d) { mOmitEveryNPixels = 0; + } else if (zoomPct >= .60d) { mOmitEveryNPixels = 0; + } else if (zoomPct >= .50d) { mOmitEveryNPixels = 8; + } else if (zoomPct >= .40d) { mOmitEveryNPixels = 7; + } else if (zoomPct >= .38d) { mOmitEveryNPixels = 6; + } else if (zoomPct >= .36d) { mOmitEveryNPixels = 5; + } else if (zoomPct >= .34d) { mOmitEveryNPixels = 3; + } else if (zoomPct >= .30d) { mOmitEveryNPixels = 2; + } else if (zoomPct >= .28d) { mOmitNPixelsThenDrawOne = 2; + } else if (zoomPct >= .26d) { mOmitNPixelsThenDrawOne = 3; + } else if (zoomPct >= .24d) { mOmitNPixelsThenDrawOne = 4; + } else if (zoomPct >= .22d) { mOmitNPixelsThenDrawOne = 5; + } else if (zoomPct >= .20d) { mOmitNPixelsThenDrawOne = 6; + } else if (zoomPct >= .18d) { mOmitNPixelsThenDrawOne = 7; + } else if (zoomPct >= .16d) { mOmitNPixelsThenDrawOne = 8; + } else if (zoomPct >= .14d) { mOmitNPixelsThenDrawOne = 9; + } else if (zoomPct >= .12d) { mOmitNPixelsThenDrawOne = 10; + } else { mOmitNPixelsThenDrawOne = 11; } for(int i=0; i < arrayLength; i++) { currByte = pUncompressedDataByteArray[i]; xWalkingRight = i * 8; + if((currByte & 0x80) > 0) { + offsetX = pPosX + (int) Math.round(xWalkingRight * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + if((currByte & 0x40) > 0) { + offsetX = pPosX + (int) Math.round((xWalkingRight + 1) * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + if((currByte & 0x20) > 0) { + offsetX = pPosX + (int) Math.round((xWalkingRight + 2) * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + if((currByte & 0x10) > 0) { + offsetX = pPosX + (int) Math.round((xWalkingRight + 3) * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + if((currByte & 0x08) > 0) { + offsetX = pPosX + (int) Math.round((xWalkingRight + 4) * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + if((currByte & 0x04) > 0) { + offsetX = pPosX + (int) Math.round((xWalkingRight + 5) * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + if((currByte & 0x02) > 0) { + offsetX = pPosX + (int) Math.round((xWalkingRight + 6) * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + if((currByte & 0x01) > 0) { + offsetX = pPosX + (int) Math.round((xWalkingRight + 7) * zoomPct); + omitSpecificPixelsByZoomFactor(offsetX, pPosY, pColorAsInt); + } + } + + } + + private void omitSpecificPixelsByZoomFactor(int pOffsetX, int pPosY, int pColorAsInt) { + boolean tShouldDrawThisPixel = true; + + // Omit every N pixels + if (mOmitEveryNPixels > 0) { + if (mPixelsDrawnCounter < (mOmitEveryNPixels - 1)) { + mPixelsDrawnCounter++; + tShouldDrawThisPixel = true; + } else { + mPixelsDrawnCounter = 0; + tShouldDrawThisPixel = false; + } + + // Omit N pixels, then draw 1 pixel (repeat) + } else if (mOmitNPixelsThenDrawOne > 0) { + if (mPixelsOmittedCounter >= mOmitNPixelsThenDrawOne) { + mPixelsOmittedCounter = 0; + tShouldDrawThisPixel = true; + } else { + mPixelsOmittedCounter++; + tShouldDrawThisPixel = false; + } + } else { + tShouldDrawThisPixel = true; + } + + // Draw the pixel if it hasn't been omitted + if (tShouldDrawThisPixel) { try { - if((currByte & 0x80) > 0) { - offsetX = pPosX + (int) Math.round(xWalkingRight * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } - if((currByte & 0x40) > 0) { - offsetX = pPosX + (int) Math.round((xWalkingRight + 1) * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } - if((currByte & 0x20) > 0) { - offsetX = pPosX + (int) Math.round((xWalkingRight + 2) * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } - if((currByte & 0x10) > 0) { - offsetX = pPosX + (int) Math.round((xWalkingRight + 3) * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } - if((currByte & 0x08) > 0) { - offsetX = pPosX + (int) Math.round((xWalkingRight + 4) * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } - if((currByte & 0x04) > 0) { - offsetX = pPosX + (int) Math.round((xWalkingRight + 5) * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } - if((currByte & 0x02) > 0) { - offsetX = pPosX + (int) Math.round((xWalkingRight + 6) * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } - if((currByte & 0x01) > 0) { - offsetX = pPosX + (int) Math.round((xWalkingRight + 7) * zoomPct); - mBufferedImageToDrawOn.setRGB(offsetX, pPosY, pColorAsInt); - } + mBufferedImageToDrawOn.setRGB(pOffsetX, pPosY, pColorAsInt); } catch (Exception e) { } } - } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |