Results 1 to 4 of 4

Thread: Problem

  1. #1

    Problem

    I have a weird problem. I'm making a LoadBMP function for the graph unit and as you may know, 1 and 4 bit bmp files can hold multiple pixels in a byte. I must read 1 pixel at a time so I used a loop and Shr and Shl to get what I need.

    but I got a problem:

    ( FF (11111111) shl 0 ) shr 4 >> 0F (00001111) - this was fine for me, but

    ( FF (11111111) shl 4 ) shr 4 >> FF (11111111) - why is this so? I thought the result would be 0F again.

    Does freepascal *save* the shifted bits?

    I thought they get deleted, but it got them back. Can someone explain please !

  2. #2

    Problem

    Free Pascal is a 32 bit compiler, so $ff shl 4= $ff0. Then $ff0 shr 4=$ff.

    However, byte($ff shl 4)=$f0 , so adding a typecast gives the result you need.

  3. #3

    Problem

    Thanks! I didn't know of such typecasts.

    No wonder you're called the Byte Master

  4. #4

    Problem

    hateshinai could you please post a more detailed subject in future. "Problem" is a bit too vague and may get overlooked due to lack of specific information.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •