J
JoeC
I am working on a graphics program but my question has nothing to do
with graphics but trying to get an algorithm to work. I set graphics
from a 16x16 grid to bits of a graphic with:
bitData[index++] = binTemp[0] * 128 + binTemp[1] * 64 +
binTemp[2] * 32 + binTemp[3] * 16 +
binTemp[4] * 8 + binTemp[5] * 4 +
binTemp[6] * 2 + binTemp[7];
But I want to populate that same pad from bits:
void populate(int num){
int bits[8] = {0,0,0,0,0,0,0,0};
int counter = 0;
int placer = 0;
BYTE temp;
clear();
std::vector<BYTE> vb = work.getBits();
std::vector<BYTE>::const_iterator itr = vb.begin();
for(int dwn = 0; dwn < work.getPixels(); dwn++){
for(int acc = 0; acc < 2; acc++){
if(acc == (num) || acc == (num+1)){
temp = *itr;
if(temp >= 128){
bits[0] = 1;
temp=-128;
}
if(temp >= 64){
bits[1] =1;
temp-=64;
}
if(temp >= 32){
bits[2] =1;
temp-=32;
}
if(temp >= 16){
bits[3] =1;
temp-=16;
}
if(temp >= 8){
bits[4] =1;
temp-=8;
}
if(temp >= 4){
bits[5] =1;
temp-=4;
}
if(temp >= 2){
bits[6] =1;
temp-=2;
}
if(temp >= 1){
bits[7] =1;
}
table[0+(counter*8)] = bits[0];
table[1+(counter*8)] = bits[1];
table[2+(counter*8)] = bits[2];
table[3+(counter*8)] = bits[3];
table[4+(counter*8)] = bits[4];
table[5+(counter*8)] = bits[5];
table[6+(counter*8)] = bits[6];
table[7+(counter*8)] = bits[7];
for(int l = 0; l != 7; l++){bits[l]=0;}
counter++;
itr++;
}
}
}
}
It does not work. It messes up if the number is over 128 that is the
first bit 10000000 is above 128. Anything thing look wrong. I will
send my program or post more code if that is needed.
You can see a functioning version of my program at:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=11996&lngWId=3
with graphics but trying to get an algorithm to work. I set graphics
from a 16x16 grid to bits of a graphic with:
bitData[index++] = binTemp[0] * 128 + binTemp[1] * 64 +
binTemp[2] * 32 + binTemp[3] * 16 +
binTemp[4] * 8 + binTemp[5] * 4 +
binTemp[6] * 2 + binTemp[7];
But I want to populate that same pad from bits:
void populate(int num){
int bits[8] = {0,0,0,0,0,0,0,0};
int counter = 0;
int placer = 0;
BYTE temp;
clear();
std::vector<BYTE> vb = work.getBits();
std::vector<BYTE>::const_iterator itr = vb.begin();
for(int dwn = 0; dwn < work.getPixels(); dwn++){
for(int acc = 0; acc < 2; acc++){
if(acc == (num) || acc == (num+1)){
temp = *itr;
if(temp >= 128){
bits[0] = 1;
temp=-128;
}
if(temp >= 64){
bits[1] =1;
temp-=64;
}
if(temp >= 32){
bits[2] =1;
temp-=32;
}
if(temp >= 16){
bits[3] =1;
temp-=16;
}
if(temp >= 8){
bits[4] =1;
temp-=8;
}
if(temp >= 4){
bits[5] =1;
temp-=4;
}
if(temp >= 2){
bits[6] =1;
temp-=2;
}
if(temp >= 1){
bits[7] =1;
}
table[0+(counter*8)] = bits[0];
table[1+(counter*8)] = bits[1];
table[2+(counter*8)] = bits[2];
table[3+(counter*8)] = bits[3];
table[4+(counter*8)] = bits[4];
table[5+(counter*8)] = bits[5];
table[6+(counter*8)] = bits[6];
table[7+(counter*8)] = bits[7];
for(int l = 0; l != 7; l++){bits[l]=0;}
counter++;
itr++;
}
}
}
}
It does not work. It messes up if the number is over 128 that is the
first bit 10000000 is above 128. Anything thing look wrong. I will
send my program or post more code if that is needed.
You can see a functioning version of my program at:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=11996&lngWId=3