sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Jpg textures in *.skp

    Scheduled Pinned Locked Moved Developers' Forum
    34 Posts 5 Posters 2.4k Views 5 Watching
    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.
    • thomthomT Offline
      thomthom
      last edited by

      Are you sniffing out the image size instead of reading the integer in front of the image data?

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        SUMaterialData.png

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • S Offline
          soldatino
          last edited by

          I did not attempt to sniff the jpg size because the compress header has particularity different of other picture formats, it is not a true header, and I dont have enough knowledge about it.
          But your screeen shot is very good. I only knew the FF+FE recurrence. Your confirmation is important for me, with your addictionally info also.
          Thanks!
          ps I now can improve the exact png filename also, that at this moment I did not still search...

          r3nDer tools

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @soldatino said:

            I did not attempt to sniff the jpg size because the compress header has particularity different of other picture formats, it is not a true header, and I dont have enough knowledge about it.

            What header are you referring to?

            I'm not sure if we are referring to the same thing - maybe this screenshot will help.
            SUMaterialStart.png

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @soldatino said:

              I only knew the FF+FE recurrence. Your confirmation is important for me, with your addictionally info also.

              Did you look at the text file I attached earlier? with notes on the format.

              
              SketchUp File Format
              Reverse Engineering Attempt by Thomas Thomassen
              [thomas@thomthom.net]
              
              
              ////////////////////////////////////////////////////////////////////////////////
              /// BLOCKS /////////////////////////////////////////////////////////////////////
              
              There are reoccuring patterns. Looks like block signatures.
              Blocks Signature; FF FE FF ??
              The next byte gives the size of the block (or block name)
              If the UBYTE after the signature is not NULL then it appears to be a UTF-16LE
              string. UTF-16LE string signature? Many places there is no string, the ?? byte
              is just NULL.
              
              Some places (FF FF) indicates a new section or area. Bytes before that mark
              might be important. For the Material and Layer section there is four bytes with
              the total number of Materials and Layers.
              (FF FF) appear to be preseeded by four bytes. ID number/signature?
              
              Apart from the byte indicating the Unicode string there doesn't seem to be any
              bytes that indicates the size of the blocks. Looks like it's required to know
              the structure to read the file. Even just part of it.
              Due to plugins there could be extra information and blocks inserted.
              Components also complicates things as they appear as files within the file. Due
              to this you can not blindly scan for strings or byte sequences.
              
              What is the pattern to the file structure?
              How do you scan/skip to the interesting data reliably?
              
              /// THEORY /////////////////////////////////////////////////////////////////////
              Blocks (Sections);
              2 bytes - Signature (FF FF)
              2 bytes - (Short) Block ID or VersionMap referance
              2 bytes - (Short) Size of Block Name
              ? bytes (Size of Block Name) - Name of Block (ASCII)
              
              
              FF FE FF Signature indicates Sub-Blocks. (Blocks inside the sections)
              
              
              
              ================================================================================
              
              TIME_T - 32-bit value representing date and time in C using the format
                       'MM/dd/yyyy hh;mm;ss'. time_t is a 32-bit integer representing the
              		 number of seconds since 01/01/1970 12;00 AM.
              
              ================================================================================
              
              
              
              /// HEADER BLOCKS //////////////////////////////////////////////////////////////
              ////////////////////////////////////////////////////////////////////////////////
              /// SkechUp File ID ////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size (in characters)
              | 28 bytes (14 Unicode Characters) - 'SketchUp Model'
              +------------------------------------------------------------------------------+
              ////////////////////////////////////////////////////////////////////////////////
              /// Version Number /////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size
              | Variable Bytes (Block Name Size) - Version Number wrapped in curly brackets
              +------------------------------------------------------------------------------+
              | 16 Bytes - ? (Random every time, even when doing a Save As)
              |
              |   When doing a Save As the files should be identical, but this section of data
              |   differs anyway. (Tested with a file doing Save As two times. Result was
              |   three files with the same size but had differences in two areas of this data
              |   chunk.
              +------------------------------------------------------------------------------+
              ////////////////////////////////////////////////////////////////////////////////
              /// Time Stamp /////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte  - Block Name Size (00)
              | 4 bytes - Timestamp of when file was saved. Appears to be UTC regardless of
              |           locale. (TIME_T)
              +------------------------------------------------------------------------------+
              
              /// VERSION MAP ////////////////////////////////////////////////////////////////
              ////////////////////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 6 bytes - Section Sig (FF FF 00 00 0B 00)
              | 11 bytes - 'CVersionMap'
              +------------------------------------------------------------------------------+
              ~~~ Repeat ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size
              | Variable Bytes (Block Name Size) - Name of Capability
              +------------------------------------------------------------------------------+
              | 2 bytes - ? (Capability ID?) Relates to Short Int after Blocks.
              | 2 bytes - ?
              +------------------------------------------------------------------------------+
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size
              | 36 Bytes (18 Unicode Characters) - 'End-Of-Version-Map'
              +------------------------------------------------------------------------------+
              
              ////////////////////////////////////////////////////////////////////////////////
              /// Unknown Data ///////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 16 Bytes - ?
              |    00 00 00 00 01 00 00 00 B0 04 00 00
              | !  01 or 03
              |    00 00 00
              |
              |     Theory; 4 Ints
              |     4 bytes - ? (00 00 00 00) Unsigned Int; 0
              |     4 bytes - ? (01 00 00 00) Unsigned Int; 1
              |     4 bytes - ? (B0 04 00 00) Unsigned Int; 1200
              |     4 bytes - ? (03 00 00 00) Unsigned Int; 3 OR (01 00 00 00)
              |
              +------------------------------------------------------------------------------+
              
              ////////////////////////////////////////////////////////////////////////////////
              /// CDib Block /////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 6 bytes - Section Sig (FF FF 03 00 04 00)
              | 4 bytes - 'CDib'
              +------------------------------------------------------------------------------+
              | 4 bytes - ? (04 00 00 00)
              | 4 bytes - Unsigned Int - Size of Image Data (PNG file)
              | {PNG DATA}
              | 10 bytes - ? (01 00 00 00 00 00 00 00 00 00)
              +------------------------------------------------------------------------------+
              
              ////////////////////////////////////////////////////////////////////////////////
              /// Camera /////////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size (00)
              +------------------------------------------------------------------------------+
              | 6 bytes - Section Sig (FF FF 05 00 07 00)
              | 4 bytes - 'CCamera'
              +------------------------------------------------------------------------------+
              | 139 bytes - ?
              +------------------------------------------------------------------------------+
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size
              +------------------------------------------------------------------------------+
              | 236 bytes - ? (!) Does not match for .skp files with V-Ray material
              +------------------------------------------------------------------------------+
              
              ////////////////////////////////////////////////////////////////////////////////
              /// Materials //////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 4 bytes - Material Count
              +------------------------------------------------------------------------------+
              | 6 bytes - Section Sig (FF FF 0C 00 09 00)
              | 9 bytes - 'CMaterial'
              +------------------------------------------------------------------------------+
              | 2 bytes - ? (00 00) Or other data if the material has an attribute attached.
              +------------------------------------------------------------------------------+
              ~~~ Repeat by number of Material Count ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              /// Material Block /////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size
              | Variable Bytes (Block Name Size) - Material Name
              +------------------------------------------------------------------------------+
              | 1 byte - ?
              | 1 byte - ?
              | 1 byte - Red
              | 1 byte - Green
              | 1 byte - Blue
              | 1 byte - Alpha
              +------------------------------------------------------------------------------+
              /// Unknown ////////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | EMPTY
              +------------------------------------------------------------------------------+
              | 21 bytes - Unknown
              +------------------------------------------------------------------------------+
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              
              ////////////////////////////////////////////////////////////////////////////////
              /// Layers /////////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 4 bytes - Layer Count
              +------------------------------------------------------------------------------+
              | 6 bytes - Section Sig (FF FF 02 00 06 00)
              | 6 bytes - 'CLayer'
              +------------------------------------------------------------------------------+
              | 2 bytes - ? (00 00)
              +------------------------------------------------------------------------------+
              
              ~~~ Repeat by number of Layer Count ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              /// Layer Block ////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | 3 bytes - Block Signature (FF FE FF)
              | 1 byte - Block Name Size
              | Variable Bytes (Block Name Size) - Layer Name
              +------------------------------------------------------------------------------+
              | 1 byte - Visibility (00 or 01)
              | 1 byte - ?
              | 1 byte - ?
              +------------------------------------------------------------------------------+
              /// Material Block /////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | REF; Material Block
              |      Material block name; Layer_{Layer Name}
              | 4 bytes - ? Extra bytes trailing the Layer Material Blocks.
              +------------------------------------------------------------------------------+
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              
              /// Unknown ////////////////////////////////////////////////////////////////////
              +------------------------------------------------------------------------------+
              | EMPTY
              +------------------------------------------------------------------------------+
              | 6 bytes - ? (0C 00 00 00 00)
              | 4 bytes - CEdge Count? (Unlikely. Return 18 on model with 12 edges)
              | 2 bytes - ? (FF FF)
              | 4 bytes - ? (02 00 05 00)
              | 5 bytes - 'CEdge'
              +------------------------------------------------------------------------------+
              
              

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • S Offline
                soldatino
                last edited by

                Yes I downloaded it but I did not found jpg blocks and I thought that the markers was the signature only for the structures of objects and the jpgs were an unexplored different attachment.
                Addictionally I thought that SU maintained an area of overwriting for the jpg images in the file, because I find garbage (jpg started and not ended, but it is possible that I was wrong) and I got the idea of a single physical space of storage...

                r3nDer tools

                1 Reply Last reply Reply Quote 0
                • S Offline
                  soldatino
                  last edited by

                  @thomthom said:

                  @soldatino said:

                  I did not attempt to sniff the jpg size because the compress header has particularity different of other picture formats, it is not a true header, and I dont have enough knowledge about it.

                  What header are you referring to?

                  I'm not sure if we are referring to the same thing - maybe this screenshot will help.
                  [attachment=0:3ag13v96]<!-- ia0 -->SUMaterialStart.png<!-- ia0 -->[/attachment:3ag13v96]

                  exactly I was talking of the header of the jpg file itself

                  updated 0.0.9
                  faster, filename's search uses only ("jpg" or "IEND" strings) + &FF&FE&FF pointer

                  r3nDer tools

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    soldatino
                    last edited by

                    Well I need win API in SU's Ruby because I want write a rb plugin with the same code I use in T-Magnifier, but it seems that I cannot without complicated extensions ! 😲
                    All the languages can access to the win API...

                    r3nDer tools

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      You can use Win32 API...
                      http://ruby-doc.org/docs/ProgrammingRuby/html/lib_windows.html

                      Thomas Thomassen — SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        soldatino
                        last edited by

                        @thomthom said:

                        You can use Win32 API...
                        http://ruby-doc.org/docs/ProgrammingRuby/html/lib_windows.html

                        thanks but the meaning of the error vs
                        require 'Win32API'
                        is that the build-in Ruby in SU does not have this extension? Does the user need to install ruby runtime components?

                        r3nDer tools

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          one need a win32api.so file - there are some SU plugins that already ship with this. It's the only file you need to bundle.

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • S Offline
                            soldatino
                            last edited by

                            thanks , I now see that about it there are topics in the forum...

                            r3nDer tools

                            1 Reply Last reply Reply Quote 0
                            • 1
                            • 2
                            • 2 / 2
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement