🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Working with jpg images

    Core 2
    4
    11
    18.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mikemoy
      last edited by mikemoy

      The factor demo for the Core2 is very nice.
      I found the thread "Lesson 1.2.1. LCD. How to create image array" but that is not what is used in the factory demo.
      They use, Disbuff.drawJpg(CoverImage,21301,0,0,240,240,0,0);
      The lesson thread uses drawBitmap

      What I would like to know is how to take a .jpg image, convert it to a C file and use drawJpg to throw it on the LCD.
      Is there any info on how to do that ?

      Thanks

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3 @mikemoy
        last edited by

        @mikemoy You don't need to, you can save jpgs to the core2 and load them directly.
        btw the lesson was written for the core1 a long time ago.

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        D 1 Reply Last reply Reply Quote 0
        • M
          murraypaul
          last edited by murraypaul

          I have a M5Paper, not a Core2, but the APIs look very similar.
          You can use something like bin2header (https://github.com/AntumDeluge/bin2header) to convert your jpg file to a C header file and include that in your project. It will start with something like:

          static const unsigned char my_file_name_jpg[] = {...
          

          You can then use the memory buffer form of drawJpg:

                void drawJpg(const uint8_t *jpg_data, size_t jpg_len, uint16_t x = 0,
                            uint16_t y = 0, uint16_t maxWidth = 0, uint16_t maxHeight = 0,
                            uint16_t offX = 0, uint16_t offY = 0,
                            jpeg_div_t scale = JPEG_DIV_NONE);
          

          Like this:

          drawJpg(my_file_name_jpg,sizeof(my_file_name_jpg),x,y,...)
          

          (As the other poster said, this might not be the best way of doing it, but it is available.)

          1 Reply Last reply Reply Quote 0
          • M
            mikemoy
            last edited by

            Thank you for the detailed explanation.
            I wound up using "Bin2C" from segger.com because I am a windows guy ;-)
            Bin2C

            Got it working now thanks.

            1 Reply Last reply Reply Quote 0
            • D
              Delchi
              last edited by

              Could you please outline how this is done? I've been trying for days with no luck. It seems only PNG's are accepted , and the ones I resize look pixelated and horrible.

              Thanks ,

              M 1 Reply Last reply Reply Quote 0
              • D
                Delchi @ajb2k3
                last edited by

                @ajb2k3 Can you please outline how this is done? I have been unable to do this at all with my core2. With UIFlow it only allows PNG uploads, and with Audrino there is no way to upload the JPG image to the core2. Google searches show 1/2 the time that it can't be done, and that I should upgrade to a FIRE , and 1/2 the time say it's possible but not how to do it.

                Thanks ,

                • D
                ajb2k3A 1 Reply Last reply Reply Quote 0
                • ajb2k3A
                  ajb2k3 @Delchi
                  last edited by ajb2k3

                  @delchi Hi, I am currently rewriting my book at the moment and about to redo the whole image section to make it easy to understand.
                  jpegs can most defiantly be done in UIFLOW as I have just done it.

                  Images must not be bigger than the screen size.
                  Images must be indexed.
                  Images must be compressed,
                  Images must have all non used colour data removed,
                  For CoreInk image must be in 1bit mode,
                  For M5paper images must be in 16bit grayscale,
                  Images must be no more than 50KB in size.
                  My current book version found here https://github.com/Ajb2k3/UIFlowHandbook/blob/master/UIFlowhandbook.pdf has the instructions in it.

                  UIFlow, so easy an adult can learn it!
                  If I don't know it, be patient!
                  I've ether not learned it or am too drunk to remember it!
                  Author of the WIP UIFlow Handbook!
                  M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                  D 2 Replies Last reply Reply Quote 0
                  • M
                    mikemoy @Delchi
                    last edited by

                    @delchi I didn't have any luck with JPGS, so i just used PNG.

                    1 Reply Last reply Reply Quote 0
                    • D
                      Delchi @ajb2k3
                      last edited by

                      @ajb2k3 Thank you ! I'm using a core 2 and it seems like no one has had an easy time with this. I keep finding odd bugs like loops not working correctly and ghost labels popping up and it's all very frustrating w/out a solid guide. I'll keep an eye out for your book when it covers the core2.

                      1 Reply Last reply Reply Quote 0
                      • D
                        Delchi @ajb2k3
                        last edited by

                        @ajb2k3 And now after an afternoon of a successful PNG image working, it just suddenly stopped, and won't even allow an upload. No error message , no nothing.

                        Frustration wins today. I can't believe how wonky this all is :)

                        ajb2k3A 1 Reply Last reply Reply Quote 0
                        • ajb2k3A
                          ajb2k3 @Delchi
                          last edited by

                          @delchi I take it you are using UIFLOW online.
                          In that case it just means that the server dropped and crashed due to the amount of people online.

                          UIFlow, so easy an adult can learn it!
                          If I don't know it, be patient!
                          I've ether not learned it or am too drunk to remember it!
                          Author of the WIP UIFlow Handbook!
                          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post