0

Is it possible in c# like in c++, to write to file bit by bit. for exmaple write one bit every iteration of for loop.

 void QT (int MINX, int MAXX,int MINY, int MAXY){
    short val = (short)normalizedImg[MINX, MINY];
    for(int x = MINX; x < MAXX; x++){
        for(int y = MINY; y < MAXY; y++){
            if (val != (short)normalizedImg[x,y])
                //Math.Pow(val - (short)normalizedImg[x, y], 2) > Math.Pow(T, 2)
                { 
                //writebit(1);
                QT(MINX,(MINX+MAXX)/2,MINY,(MINY+MAXY)/2);
                QT(MINX,(MINX+MAXX)/2,(MINY+MAXY)/2,MAXY);                
                QT((MINX+MAXX)/2,MAXX,MINY,(MINY+MAXY)/2);
                QT((MINX+MAXX)/2,MAXX,(MINY+MAXY)/2,MAXY); 
                return;
                }
            }

        }
        //Writebit(0)

    }

The problem is if I'd do this with the help of string, things get very slow very fast.

3
  • It is possible byte by byte, not bit by bit. If you want to do so, you must accumulate the bits yourself. use bitwise or (|) and shift operations << or >> depending whether you add new bits to the right or left. Commented Oct 21, 2017 at 18:55
  • Will try this, thank you Commented Oct 21, 2017 at 18:59
  • @RokPotočnik See this answer here: stackoverflow.com/a/7067744/633098 Commented Oct 21, 2017 at 19:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.