3v4l.org

run code in 300+ 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 = 46
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 46
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 12
filename:       /in/QJ3Lu
function name:  (null)
number of ops:  110
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, ->46
         19    > > FE_FETCH_R                                               $42, !6, ->46
   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                                               'implode'
         37        SEND_VAL                                                 ''
         38        INIT_FCALL                                               'array_map'
         39        SEND_VAL                                                 'chr'
         40        SEND_VAR                                                 !8
         41        DO_ICALL                                         $48     
         42        SEND_VAR                                                 $48
         43        DO_ICALL                                         $49     
         44        ASSIGN_OP                                     8          !5, $49
   24    45      > JMP                                                      ->19
         46    >   FE_FREE                                                  $42
   29    47        STRLEN                                           ~51     !5
         48        ASSIGN                                                   !9, ~51
   34    49        INIT_FCALL                                               'pack'
   35    50        SEND_VAL                                                 'CCCxCCCx'
   37    51        SEND_VAL                                                 255
         52        SEND_VAL                                                 255
         53        SEND_VAL                                                 255
   38    54        SEND_VAL                                                 0
         55        SEND_VAL                                                 0
         56        SEND_VAL                                                 0
         57        DO_ICALL                                         $53     
   34    58        ASSIGN                                                   !10, $53
   40    59        STRLEN                                           ~55     !10
         60        ASSIGN                                                   !11, ~55
   46    61        ASSIGN                                                   !12, 40
   47    62        ASSIGN                                                   !13, 1
   48    63        ASSIGN                                                   !14, 1
   49    64        ASSIGN                                                   !15, 0
   50    65        ASSIGN                                                   !16, 2835
   51    66        ASSIGN                                                   !17, 2835
   52    67        ASSIGN                                                   !18, 2
   53    68        ASSIGN                                                   !19, 0
   54    69        INIT_FCALL                                               'pack'
         70        SEND_VAL                                                 'VVVvvVVVVVV'
         71        SEND_VAR                                                 !12
         72        SEND_VAR                                                 !1
         73        SEND_VAR                                                 !2
         74        SEND_VAR                                                 !13
         75        SEND_VAR                                                 !14
         76        SEND_VAR                                                 !15
         77        SEND_VAR                                                 !9
         78        SEND_VAR                                                 !16
         79        SEND_VAR                                                 !17
         80        SEND_VAR                                                 !18
         81        SEND_VAR                                                 !19
         82        DO_ICALL                                         $65     
         83        ASSIGN                                                   !20, $65
   59    84        ASSIGN                                                   !21, 14
   60    85        ADD                                              ~68     !21, !12
         86        ADD                                              ~69     ~68, !11
         87        ASSIGN                                                   !22, ~69
   61    88        ADD                                              ~71     !22, !9
         89        ASSIGN                                                   !23, ~71
   62    90        INIT_FCALL                                               'pack'
         91        SEND_VAL                                                 'CCVxxxxV'
         92        SEND_VAL                                                 66
         93        SEND_VAL                                                 77
         94        SEND_VAR                                                 !23
         95        SEND_VAR                                                 !22
         96        DO_ICALL                                         $73     
         97        ASSIGN                                                   !24, $73
   66    98        CONCAT                                           ~75     !24, !20
         99        CONCAT                                           ~76     ~75, !10
        100        CONCAT                                           ~77     ~76, !5
        101        ASSIGN                                                   !25, ~77
   67   102        INIT_FCALL                                               'base64_encode'
        103        SEND_VAR                                                 !25
        104        DO_ICALL                                         $79     
        105        ASSIGN                                                   !26, $79
   70   106        ECHO                                                     '%3Cimg+src%3D%22data%3Aimage%2Fbitmap%3Bbase64%2C+'
        107        ECHO                                                     !26
        108        ECHO                                                     '%22+style%3D%22image-rendering%3A+crisp-edges%3Bwidth%3A+100px%3Bheight%3A+%3B%22%2F%3E'
        109      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.1 ms | 1409 KiB | 27 Q