Thread: iLiad Fixing iPdf for iRex
View Single Post
Old 01-31-2007, 10:38 PM   #47
yunhaid
Enthusiast
yunhaid doesn't litteryunhaid doesn't litter
 
Posts: 29
Karma: 147
Join Date: Jan 2007
hi, soctt.
i used your code in translate mono8 to mono4, in fact, i want to translate mono8 to mono2, how can i modify this code? thank you.


{
// Get Mono 8 pixel and add error distribution
origGrey = *p + errorRight + errors[x+1];

// Convert pixel to Mono 4, clip < 0 and > Mono 4
if (origGrey <= 0) {
grey = 0;
} else if (origGrey >= 0x00ff) {
grey = 0x00ff; // No error for white of 255
} else {
grey = origGrey & 0x00f0;
}

// Put Mono 4 pixel with distributed error back
*p = grey;

// Calculate error
error = origGrey - grey;

// Distribute error
errorRight = (error * 7) >> 4;
errors[x] += (error * 3) >> 4;
errors[x+1] = ((error * 5) >> 4) + errDownRight;
errDownRight = error >> 4;
}
yunhaid is offline   Reply With Quote