저는 마조히스트이기 때문에 8 비트 PNG 파일을 디코딩하기 위해 C로 무언가를 쓰려고합니다. libpng을 재발견하는 것 ...)이미지 디코딩의 컨텍스트에서 "부호없는 모듈러스 256"이란 의미는 무엇입니까?
내 deflated, 필터링되지 않은 데이터 버퍼에있는 물건이 틀림없이 소스 이미지와 닮았지만 (여전히 아래를 보시오), 여전히, erm, filtering algorithms을 구현 한 것으로 뭔가 가짜 일 것이라고 확신합니다. 그들 대부분은 매우 간단하지만, 내가 수학에서 좋은으로 또는 어느 빌려 - 공상 과학 과정을 촬영 한하지의 docs에서 이해하지 못하는 한 가지 중요한 일이있다 :
부호없는 산술 모듈 (256)을 사용하는, 그래서 입력과 출력이 모두 바이트에 맞는지 확인하십시오.
그게 무슨 뜻입니까?
누군가가 내가 매우 감사 할 것이라고 말할 수 있다면!
참고로 (나는 엉터리 C 죄송) 같이 docs 모습에서 설명한 필터링 알고리즘 내 멍청이 구현 :
unsigned char paeth_predictor (unsigned char a, unsigned char b, unsigned char c) {
// a = left, b = above, c = upper left
char p = a + b - c; // initial estimate
char pa = abs(p - a); // distances to a, b, c
char pb = abs(p - b);
char pc = abs(p - c);
// return nearest of a,b,c,
// breaking ties in order a,b,c.
if (pa <= pb && pa <= pc) return a;
else if (pb <= pc) return b;
else return c;
}
void unfilter_sub(char* out, char* in, int bpp, int row, int rowlen) {
for (int i = 0; i < rowlen; i++)
out[i] = in[i] + (i < bpp ? 0 : out[i-bpp]);
}
void unfilter_up(char* out, char* in, int bpp, int row, int rowlen) {
for (int i = 0; i < rowlen; i++)
out[i] = in[i] + (row == 0 ? 0 : out[i-rowlen]);
}
void unfilter_paeth(char* out, char* in, int bpp, int row, int rowlen) {
char a, b, c;
for (int i = 0; i < rowlen; i++) {
a = i < bpp ? 0 : out[i - bpp];
b = row < 1 ? 0 : out[i - rowlen];
c = i < bpp ? 0 : (row == 0 ? 0 : out[i - rowlen - bpp]);
out[i] = in[i] + paeth_predictor(a, b, c);
}
}
그리고 이미지 제가 보는 :
소스
Source http://img220.imageshack.us/img220/8111/testdn.png
출력
Output http://img862.imageshack.us/img862/2963/helloworld.png
확실치 않지만 모든 곳에서'char' 대신'unsigned char'을 시도해 보셨습니까? –
@Mike Dunlavey - 예, 기본적으로 마술 조합이 이루어질 때까지 여러 장소에서'서명되지 않은 char '을 추가하는 것으로 끝났습니다! – Mikesname