Add support for characters starting with a set pixel.

This commit is contained in:
Stefan `Sec` Zehl 2011-05-16 00:15:39 +02:00
parent d3882b0b80
commit 1aaf25d5cc
3 changed files with 20 additions and 5 deletions

View File

@ -50,6 +50,11 @@ uint8_t * pk_decode(const uint8_t * data,int * len){
int pos=0; // Decoder internal: current bit position (0..7) int pos=0; // Decoder internal: current bit position (0..7)
int nyb; // Decoder internal: current nibble / value int nyb; // Decoder internal: current nibble / value
if(data[ctr]>>4 == 14){ // Char starts with 1-bits.
gnn();
curbit=1;
};
while(ctr<length){ /* Iterate the whole input stream */ while(ctr<length){ /* Iterate the whole input stream */
/* Get next encoded nibble and decode */ /* Get next encoded nibble and decode */

View File

@ -89,6 +89,13 @@ int decode(char c){
int curbit=0; // Decoder internal: current bit (1 or 0) int curbit=0; // Decoder internal: current bit (1 or 0)
int pos=0; // Decoder internal: current bit position (0..7) int pos=0; // Decoder internal: current bit position (0..7)
int nyb; // Decoder internal: current nibble / value int nyb; // Decoder internal: current nibble / value
if(font->au8FontTable[off+0]>>4 == 14){
// HACK: char starts with 1-bits,
gnn();
curbit=1;
};
while(ctr<length){ /* Iterate the whole input stream */ while(ctr<length){ /* Iterate the whole input stream */
/* Get next encoded nibble and decode */ /* Get next encoded nibble and decode */
@ -168,3 +175,4 @@ int main(void){
exit(0); exit(0);
} }

View File

@ -307,9 +307,6 @@ sub pk_rle {
my $line=join("",@$char);; my $line=join("",@$char);;
my $fpx=substr($line,0,1);
warn "first pixel ==1 - Encoder will do stupid things..." if $fpx ==1 ;
my @out; my @out;
while($line=~/./){ while($line=~/./){
$line=~s/^(0*)(\[\d+\])?(1*)(\[\d+\])?//; $line=~s/^(0*)(\[\d+\])?(1*)(\[\d+\])?//;
@ -362,8 +359,12 @@ sub pk_encode {
my $n=$1-1; # this deviates from PK spec, i think. my $n=$1-1; # this deviates from PK spec, i think.
push @enc,14,pk_encode_long($1-1); push @enc,14,pk_encode_long($1-1);
}; };
}elsif($_ == 0){ }elsif($_ == 0){ # Encoding a 0 will only happen at the start of
warn "Encoder asked to encode a zero?"; # Shouldn't happen. # character if "first pixel" is 1 instead of 0.
# HACK: We transmit this fact to the decoder
# by encoding a "14"-nibble which would be
# illegal at this point anyway.
push @enc,14;
}elsif($_ <= $dyn){ # Short length }elsif($_ <= $dyn){ # Short length
push @enc,$_; push @enc,$_;
}elsif($_ <= 16*(13-$dyn)+$dyn){ # Medium length }elsif($_ <= 16*(13-$dyn)+$dyn){ # Medium length
@ -417,3 +418,4 @@ sub do_pk {
return make_bytes(@enc); return make_bytes(@enc);
}; };