1 31 package org.pdfbox.pdmodel.graphics.predictor; 32 33 43 public class Up extends PredictorAlgorithm 44 { 45 48 public void encodeLine(byte[] src, byte[] dest, int srcDy, int srcOffset, 49 int destDy, int destOffset) 50 { 51 int bpl = getWidth()*getBpp(); 52 if (srcOffset - srcDy < 0) 54 { 55 if (0 < getHeight()) 56 { 57 for (int x = 0; x < bpl; x++) 58 { 59 dest[destOffset + x] = src[srcOffset + x]; 60 } 61 } 62 } 63 else 64 { 65 for (int x = 0; x < bpl; x++) 66 { 67 dest[destOffset + x] = (byte) (src[srcOffset + x] - src[srcOffset 68 + x - srcDy]); 69 } 70 } 71 } 72 73 76 public void decodeLine(byte[] src, byte[] dest, int srcDy, int srcOffset, 77 int destDy, int destOffset) 78 { 79 int bpl = getWidth()*getBpp(); 81 if (destOffset - destDy < 0) 82 { 83 if (0 < getHeight()) 84 { 85 for (int x = 0; x < bpl; x++) 86 { 87 dest[destOffset + x] = src[srcOffset + x]; 88 } 89 } 90 } 91 else 92 { 93 for (int x = 0; x < bpl; x++) 94 { 95 dest[destOffset + x] = (byte) (src[srcOffset + x] + dest[destOffset 96 + x - destDy]); 97 } 98 } 99 } 100 } 101 | Popular Tags |