Help for this page

Select Code to Download


  1. or download this
    RTFM background:
    
    ...
    %u    an unsigned integer, in decimal
    %hu -> unsigned  C type "short"
    This is Exactly the contents of the Perl variable as verified by C
    
  2. or download this
    Test program ouput:
    Running C:\bin\bb.pl   Wed Jan  6 13:26:28 2016
    ...
    Argument "+^\" isn't numeric in printf at C:\bin\bb.pl line 179, <FOO>
    + line 168.
    
    Number 7360 Packed into 'S': h 0, d 0, hu 0, b 0, s +?
    
  3. or download this
    Perl Code:
    sub perl_pack_print()  {
    ...
        printf("Number $xres Packed into 'S': h %x, d %d, hu %hu, b %b, s 
    +%s\n",
            $pxres, $pxres, $pxres, $pxres, $pxres);
    }
    
  4. or download this
    C dump verification code:
    // Dump given file as hex, dec, float, string...
    ...
            usbuf[0], char_8_ptr[0], char_8_ptr[1]);
        exit(0);
    }  // End Main().
    
  5. or download this
        $hdr[16]=pack("S", 7360);
        $hdr[22]=pack("S", 4912);
        printf("FIXED?  HDR[16]=$hdr[16], HDR[22]=$hdr[22]\n");
    
  6. or download this
    Read 1376 B from d:/pic/misc/gray.1376b.3689x2462.hdr
    RGB[16]=3689, [22]=2462
    FIXED?  HDR[16]=&#9492;&#8735;, HDR[22]=0&#8252;
    
  7. or download this
        @hdr=unpack("S*", $hdr);  # RAW RGB Unsigned Short array
        printf("PrInTf:: RGB[16]=%hu, [22]=%d\n", $hdr[16], $hdr[22]);
        print ("pRInT :: RGB[16]=$hdr[16], [22]=$hdr[22]\n");  =>
    PrInTf:: RGB[16]=3689, [22]=2462
    pRInT :: RGB[16]=3689, [22]=2462
    
  8. or download this
        open(H, "<$hfn");  binmode H;
        printf("Read $bread B from $hfn\n");
        @hdr=unpack("S*", $hdr);  # RAW RGB Unsigned Short array
    
  9. or download this
    printf("FIXED?  HDR[16]=$hdr[16], HDR[22]=$hdr[22]\n");  =>
    FIXED?  HDR[16]=&#9492;&#8735;, HDR[22]=0&#8252;