3v4l.org

run code in 500+ PHP versions simultaneously
<?php $pixelDataArray = array( "11101010111", "10101010101", "11101110111", "10001010100", "10001010100", ); //First to convert the input into a pixel array or bitmap data, each line on the pixel array should be dword/32bit/4bytes aligned. $pixelWidth = strlen($pixelDataArray[0]); $pixelHeight = count($pixelDataArray); $dwordAlignment = 32 - ($pixelWidth % 32); if ($dwordAlignment == 32) { $dwordAlignment = 0; } $dwordAlignedLength = $pixelWidth + $dwordAlignment; //Now we can proper align the string then convert it to a array of 1 byte integers and after to a binary string. $pixelArray = ''; foreach (array_reverse($pixelDataArray) as $row) { $dwordAlignedPixelRow = str_pad($row, $dwordAlignedLength, '0', STR_PAD_RIGHT); $integerPixelRow = array_map('bindec', str_split($dwordAlignedPixelRow, 8)); $pixelArray .= implode('', array_map('chr', $integerPixelRow)); } $pixelArraySize = \strlen($pixelArray); //Then lets build the color table $colorTable = pack( 'CCCxCCCx', //blue, green, red 255, 255, 255, // 0 color 0, 0, 0 // 1 color ); $colorTableSize = \strlen($colorTable); //Now the bitmap information header, for better support BITMAPINFOHEADER (40 bytes header) will be used. $dibHeaderSize = 40; $colorPlanes = 1; $bitPerPixel = 1; $compressionMethod = 0; //BI_RGB/NONE $horizontal_pixel_per_meter = 2835; $vertical_pixel_per_meter = 2835; $colorInPalette = 2; $importantColors = 0; $dibHeader = \pack('VVVvvVVVVVV', $dibHeaderSize, $pixelWidth, $pixelHeight, $colorPlanes, $bitPerPixel, $compressionMethod, $pixelArraySize, $horizontal_pixel_per_meter, $vertical_pixel_per_meter, $colorInPalette, $importantColors); //The last part is the file header $bmpFileHeaderSize = 14; $pixelArrayOffset = $bmpFileHeaderSize + $dibHeaderSize + $colorTableSize; $fileSize = $pixelArrayOffset + $pixelArraySize; $bmpFileHeader = pack('CCVxxxxV', \ord('B'), \ord('M'), $fileSize, $pixelArrayOffset); //Then just concat all into a single string $bmpFile = $bmpFileHeader . $dibHeader . $colorTable . $pixelArray; $bmpBase64File = base64_encode($bmpFile); ?> <img src="data:image/bitmap;base64, <?= $bmpBase64File ?>" style="image-rendering: crisp-edges;width: 100px;height: ;"/>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 43
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 43
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 12
filename:       /in/QJ3Lu
function name:  (null)
number of ops:  107
compiled vars:  !0 = $pixelDataArray, !1 = $pixelWidth, !2 = $pixelHeight, !3 = $dwordAlignment, !4 = $dwordAlignedLength, !5 = $pixelArray, !6 = $row, !7 = $dwordAlignedPixelRow, !8 = $integerPixelRow, !9 = $pixelArraySize, !10 = $colorTable, !11 = $colorTableSize, !12 = $dibHeaderSize, !13 = $colorPlanes, !14 = $bitPerPixel, !15 = $compressionMethod, !16 = $horizontal_pixel_per_meter, !17 = $vertical_pixel_per_meter, !18 = $colorInPalette, !19 = $importantColors, !20 = $dibHeader, !21 = $bmpFileHeaderSize, !22 = $pixelArrayOffset, !23 = $fileSize, !24 = $bmpFileHeader, !25 = $bmpFile, !26 = $bmpBase64File
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   12     1        FETCH_DIM_R                                          ~28     !0, 0
          2        STRLEN                                               ~29     ~28
          3        ASSIGN                                                       !1, ~29
   13     4        COUNT                                                ~31     !0
          5        ASSIGN                                                       !2, ~31
   15     6        MOD                                                  ~33     !1, 32
          7        SUB                                                  ~34     32, ~33
          8        ASSIGN                                                       !3, ~34
   16     9        IS_EQUAL                                                     !3, 32
         10      > JMPZ                                                         ~36, ->12
   17    11    >   ASSIGN                                                       !3, 0
   19    12    >   ADD                                                  ~38     !1, !3
         13        ASSIGN                                                       !4, ~38
   23    14        ASSIGN                                                       !5, ''
   24    15        INIT_FCALL                                                   'array_reverse'
         16        SEND_VAR                                                     !0
         17        DO_ICALL                                             $41     
         18      > FE_RESET_R                                           $42     $41, ->43
         19    > > FE_FETCH_R                                                   $42, !6, ->43
   25    20    >   INIT_FCALL                                                   'str_pad'
         21        SEND_VAR                                                     !6
         22        SEND_VAR                                                     !4
         23        SEND_VAL                                                     '0'
         24        SEND_VAL                                                     1
         25        DO_ICALL                                             $43     
         26        ASSIGN                                                       !7, $43
   26    27        INIT_FCALL                                                   'array_map'
         28        SEND_VAL                                                     'bindec'
         29        INIT_FCALL                                                   'str_split'
         30        SEND_VAR                                                     !7
         31        SEND_VAL                                                     8
         32        DO_ICALL                                             $45     
         33        SEND_VAR                                                     $45
         34        DO_ICALL                                             $46     
         35        ASSIGN                                                       !8, $46
   27    36        INIT_FCALL                                                   'array_map'
         37        SEND_VAL                                                     'chr'
         38        SEND_VAR                                                     !8
         39        DO_ICALL                                             $48     
         40        FRAMELESS_ICALL_2                implode             ~49     '', $48
         41        ASSIGN_OP                                         8          !5, ~49
   24    42      > JMP                                                          ->19
         43    >   FE_FREE                                                      $42
   29    44        STRLEN                                               ~51     !5
         45        ASSIGN                                                       !9, ~51
   34    46        INIT_FCALL                                                   'pack'
   35    47        SEND_VAL                                                     'CCCxCCCx'
   37    48        SEND_VAL                                                     255
         49        SEND_VAL                                                     255
         50        SEND_VAL                                                     255
   38    51        SEND_VAL                                                     0
         52        SEND_VAL                                                     0
         53        SEND_VAL                                                     0
   34    54        DO_ICALL                                             $53     
         55        ASSIGN                                                       !10, $53
   40    56        STRLEN                                               ~55     !10
         57        ASSIGN                                                       !11, ~55
   46    58        ASSIGN                                                       !12, 40
   47    59        ASSIGN                                                       !13, 1
   48    60        ASSIGN                                                       !14, 1
   49    61        ASSIGN                                                       !15, 0
   50    62        ASSIGN                                                       !16, 2835
   51    63        ASSIGN                                                       !17, 2835
   52    64        ASSIGN                                                       !18, 2
   53    65        ASSIGN                                                       !19, 0
   54    66        INIT_FCALL                                                   'pack'
         67        SEND_VAL                                                     'VVVvvVVVVVV'
         68        SEND_VAR                                                     !12
         69        SEND_VAR                                                     !1
         70        SEND_VAR                                                     !2
         71        SEND_VAR                                                     !13
         72        SEND_VAR                                                     !14
         73        SEND_VAR                                                     !15
         74        SEND_VAR                                                     !9
         75        SEND_VAR                                                     !16
         76        SEND_VAR                                                     !17
         77        SEND_VAR                                                     !18
         78        SEND_VAR                                                     !19
         79        DO_ICALL                                             $65     
         80        ASSIGN                                                       !20, $65
   59    81        ASSIGN                                                       !21, 14
   60    82        ADD                                                  ~68     !21, !12
         83        ADD                                                  ~69     ~68, !11
         84        ASSIGN                                                       !22, ~69
   61    85        ADD                                                  ~71     !22, !9
         86        ASSIGN                                                       !23, ~71
   62    87        INIT_FCALL                                                   'pack'
         88        SEND_VAL                                                     'CCVxxxxV'
         89        SEND_VAL                                                     66
         90        SEND_VAL                                                     77
         91        SEND_VAR                                                     !23
         92        SEND_VAR                                                     !22
         93        DO_ICALL                                             $73     
         94        ASSIGN                                                       !24, $73
   66    95        CONCAT                                               ~75     !24, !20
         96        CONCAT                                               ~76     ~75, !10
         97        CONCAT                                               ~77     ~76, !5
         98        ASSIGN                                                       !25, ~77
   67    99        INIT_FCALL                                                   'base64_encode'
        100        SEND_VAR                                                     !25
        101        DO_ICALL                                             $79     
        102        ASSIGN                                                       !26, $79
   70   103        ECHO                                                         '%3Cimg+src%3D%22data%3Aimage%2Fbitmap%3Bbase64%2C+'
        104        ECHO                                                         !26
        105        ECHO                                                         '%22+style%3D%22image-rendering%3A+crisp-edges%3Bwidth%3A+100px%3Bheight%3A+%3B%22%2F%3E'
        106      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.97 ms | 2067 KiB | 19 Q