SDL2 - difference between RGB888 and RGB24












2















As best I understand, both the RGB888 and RGB24 formats put their red components first, followed by green and then blue, and both formats take a total of 24 bits per pixel (because 8+8+8 = 24). Given this information both identifiers appear to describe the exact same format but I can verify that some of my code works with one of the two formats but not the other. What's the difference between the two that makes them incompatible?










share|improve this question























  • I am just guessing. But it is common for systems to use 32 bits to hold RGB24, with 8 bits being completely wasted. This is because it is often easier/faster to the addressing.

    – Aron
    Nov 27 '15 at 17:45
















2















As best I understand, both the RGB888 and RGB24 formats put their red components first, followed by green and then blue, and both formats take a total of 24 bits per pixel (because 8+8+8 = 24). Given this information both identifiers appear to describe the exact same format but I can verify that some of my code works with one of the two formats but not the other. What's the difference between the two that makes them incompatible?










share|improve this question























  • I am just guessing. But it is common for systems to use 32 bits to hold RGB24, with 8 bits being completely wasted. This is because it is often easier/faster to the addressing.

    – Aron
    Nov 27 '15 at 17:45














2












2








2








As best I understand, both the RGB888 and RGB24 formats put their red components first, followed by green and then blue, and both formats take a total of 24 bits per pixel (because 8+8+8 = 24). Given this information both identifiers appear to describe the exact same format but I can verify that some of my code works with one of the two formats but not the other. What's the difference between the two that makes them incompatible?










share|improve this question














As best I understand, both the RGB888 and RGB24 formats put their red components first, followed by green and then blue, and both formats take a total of 24 bits per pixel (because 8+8+8 = 24). Given this information both identifiers appear to describe the exact same format but I can verify that some of my code works with one of the two formats but not the other. What's the difference between the two that makes them incompatible?







sdl-2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 27 '15 at 17:30









FlaiseFlaise

31118




31118













  • I am just guessing. But it is common for systems to use 32 bits to hold RGB24, with 8 bits being completely wasted. This is because it is often easier/faster to the addressing.

    – Aron
    Nov 27 '15 at 17:45



















  • I am just guessing. But it is common for systems to use 32 bits to hold RGB24, with 8 bits being completely wasted. This is because it is often easier/faster to the addressing.

    – Aron
    Nov 27 '15 at 17:45

















I am just guessing. But it is common for systems to use 32 bits to hold RGB24, with 8 bits being completely wasted. This is because it is often easier/faster to the addressing.

– Aron
Nov 27 '15 at 17:45





I am just guessing. But it is common for systems to use 32 bits to hold RGB24, with 8 bits being completely wasted. This is because it is often easier/faster to the addressing.

– Aron
Nov 27 '15 at 17:45












2 Answers
2






active

oldest

votes


















0














They are different. If you look at SDL2/SDL_pixels.h you'll find:



SDL_PIXELFORMAT_RGB24 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
24, 3)

SDL_PIXELFORMAT_RGB888 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
SDL_PACKEDLAYOUT_8888, 24, 4)

SDL_PIXELFORMAT_RGBX8888 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
SDL_PACKEDLAYOUT_8888, 24, 4)


So RGB24 is a tightly packed three byte format (RRGGBB), while RGB888 is a four byte format with the first byte going ignored (XXRRGGBB). So the format is just confusingly named and XRGB8888 would be a more appropriate name.



Don't know why they called it RGB888 instead of XRGB8888, but they leave the leading X away on other formats as well.






share|improve this answer































    -1














    From my understanding RGB24 formats it's data in bit triplets, whereas RGB888 simply concatenates the respective byte for each channel.



    RGB24:



    RGBRGBRG BRGBRGBR GBRGBRGB


    RGB888:



    RRRRRRRR GGGGGGGG BBBBBBBB


    I highly doubt RGB24 serves a functional or technical benefit, as it would be easier to just load the byte into memory like you would do with RGB888. But I'm not sure.






    share|improve this answer
























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33962331%2fsdl2-difference-between-rgb888-and-rgb24%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      They are different. If you look at SDL2/SDL_pixels.h you'll find:



      SDL_PIXELFORMAT_RGB24 =
      SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
      24, 3)

      SDL_PIXELFORMAT_RGB888 =
      SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
      SDL_PACKEDLAYOUT_8888, 24, 4)

      SDL_PIXELFORMAT_RGBX8888 =
      SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
      SDL_PACKEDLAYOUT_8888, 24, 4)


      So RGB24 is a tightly packed three byte format (RRGGBB), while RGB888 is a four byte format with the first byte going ignored (XXRRGGBB). So the format is just confusingly named and XRGB8888 would be a more appropriate name.



      Don't know why they called it RGB888 instead of XRGB8888, but they leave the leading X away on other formats as well.






      share|improve this answer




























        0














        They are different. If you look at SDL2/SDL_pixels.h you'll find:



        SDL_PIXELFORMAT_RGB24 =
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
        24, 3)

        SDL_PIXELFORMAT_RGB888 =
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
        SDL_PACKEDLAYOUT_8888, 24, 4)

        SDL_PIXELFORMAT_RGBX8888 =
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
        SDL_PACKEDLAYOUT_8888, 24, 4)


        So RGB24 is a tightly packed three byte format (RRGGBB), while RGB888 is a four byte format with the first byte going ignored (XXRRGGBB). So the format is just confusingly named and XRGB8888 would be a more appropriate name.



        Don't know why they called it RGB888 instead of XRGB8888, but they leave the leading X away on other formats as well.






        share|improve this answer


























          0












          0








          0







          They are different. If you look at SDL2/SDL_pixels.h you'll find:



          SDL_PIXELFORMAT_RGB24 =
          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
          24, 3)

          SDL_PIXELFORMAT_RGB888 =
          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
          SDL_PACKEDLAYOUT_8888, 24, 4)

          SDL_PIXELFORMAT_RGBX8888 =
          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
          SDL_PACKEDLAYOUT_8888, 24, 4)


          So RGB24 is a tightly packed three byte format (RRGGBB), while RGB888 is a four byte format with the first byte going ignored (XXRRGGBB). So the format is just confusingly named and XRGB8888 would be a more appropriate name.



          Don't know why they called it RGB888 instead of XRGB8888, but they leave the leading X away on other formats as well.






          share|improve this answer













          They are different. If you look at SDL2/SDL_pixels.h you'll find:



          SDL_PIXELFORMAT_RGB24 =
          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
          24, 3)

          SDL_PIXELFORMAT_RGB888 =
          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
          SDL_PACKEDLAYOUT_8888, 24, 4)

          SDL_PIXELFORMAT_RGBX8888 =
          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
          SDL_PACKEDLAYOUT_8888, 24, 4)


          So RGB24 is a tightly packed three byte format (RRGGBB), while RGB888 is a four byte format with the first byte going ignored (XXRRGGBB). So the format is just confusingly named and XRGB8888 would be a more appropriate name.



          Don't know why they called it RGB888 instead of XRGB8888, but they leave the leading X away on other formats as well.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 9:13









          GrumbelGrumbel

          3,24152935




          3,24152935

























              -1














              From my understanding RGB24 formats it's data in bit triplets, whereas RGB888 simply concatenates the respective byte for each channel.



              RGB24:



              RGBRGBRG BRGBRGBR GBRGBRGB


              RGB888:



              RRRRRRRR GGGGGGGG BBBBBBBB


              I highly doubt RGB24 serves a functional or technical benefit, as it would be easier to just load the byte into memory like you would do with RGB888. But I'm not sure.






              share|improve this answer




























                -1














                From my understanding RGB24 formats it's data in bit triplets, whereas RGB888 simply concatenates the respective byte for each channel.



                RGB24:



                RGBRGBRG BRGBRGBR GBRGBRGB


                RGB888:



                RRRRRRRR GGGGGGGG BBBBBBBB


                I highly doubt RGB24 serves a functional or technical benefit, as it would be easier to just load the byte into memory like you would do with RGB888. But I'm not sure.






                share|improve this answer


























                  -1












                  -1








                  -1







                  From my understanding RGB24 formats it's data in bit triplets, whereas RGB888 simply concatenates the respective byte for each channel.



                  RGB24:



                  RGBRGBRG BRGBRGBR GBRGBRGB


                  RGB888:



                  RRRRRRRR GGGGGGGG BBBBBBBB


                  I highly doubt RGB24 serves a functional or technical benefit, as it would be easier to just load the byte into memory like you would do with RGB888. But I'm not sure.






                  share|improve this answer













                  From my understanding RGB24 formats it's data in bit triplets, whereas RGB888 simply concatenates the respective byte for each channel.



                  RGB24:



                  RGBRGBRG BRGBRGBR GBRGBRGB


                  RGB888:



                  RRRRRRRR GGGGGGGG BBBBBBBB


                  I highly doubt RGB24 serves a functional or technical benefit, as it would be easier to just load the byte into memory like you would do with RGB888. But I'm not sure.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 15 '17 at 20:02









                  Keyton StanierKeyton Stanier

                  1




                  1






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33962331%2fsdl2-difference-between-rgb888-and-rgb24%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Bressuire

                      Vorschmack

                      Quarantine