Binary file visualizer (upd. 2018-07-08) - General Discussion and Assistance - CHDK Forum
supplierdeeply

Binary file visualizer (upd. 2018-07-08)

  • 4 Replies
  • 5912 Views
*

Offline srsa_4c

  • ******
  • 4451
Binary file visualizer (upd. 2018-07-08)
« on: 05 / January / 2016, 18:47:33 »
Advertisements
I've been using (and recommending) a utility named Hexplorer and its "pixel view" for visualization purposes. Finally got fed up with its awful UI and decided to write a utility solely for this purpose.
Win32 binary and source (Lazarus + FPC  :-[) attached.
The exe needs to be placed to a writable location as it will save its .ini file there. In addition to Windows, it does work on current Wine (I actually developed it on Wine).
I hope that the UI is straightforward enough.
The features are rather basic. It is meant to be fed with a RAM dump.

https://www.virustotal.com/en/file/f31ec6c8513ca469a54d72890092d05883ecb4aa45aa59ad65bc8715f0e99827/analysis/1451938940/

Update 2018-07-08

- Low bitdepth modes are visualized differently (palette support is still missing).
- Added 4, 2, 1 bit/pixel modes

Built using Lazarus 1.8 and FPC 3.0.4.
The attached binary produces 2 detections on VirusTotal. Use it at your own risk or build from source.


History
binview_exe_win32.7z (691.02 kB - downloaded 68 times.)
binview_src_160104.7z (69.86 kB - downloaded 25 times.)
« Last Edit: 08 / July / 2018, 16:34:31 by srsa_4c »

*

Offline reyalp

  • ******
  • 14098
Re: Binary file visualizer
« Reply #1 on: 13 / February / 2016, 00:49:53 »
Very useful, thanks :)
Don't forget what the H stands for.

*

Offline Ant

  • *****
  • 509
Re: Binary file visualizer
« Reply #2 on: 11 / September / 2016, 09:39:05 »
I've added support for 14 bit raw buffers:
Code: [Select]
function getpixel_14bitraw(args: Pgpargs):TBGRAPixel;
var
  uy: UInt32;
begin
  if args^.bsp>=args^.lim then begin
    Integer(Result):=0;
    Exit;
  end;
  case args^.bsp mod 8 of
    0: begin
      uy:=(UInt32(         ((args^.pbuf+1)^)<<6)  or UInt32((args^.pbuf+0)^ div 4));
    end;
    1: begin
      uy:=(UInt32($03 and (((args^.pbuf+0)^)<<12)) or UInt32(((args^.pbuf+3)^)<<4) or UInt32((args^.pbuf+2)^ div 16));
    end;
    2: begin
      uy:=(UInt32($0f and (((args^.pbuf+2)^)<<10)) or UInt32(((args^.pbuf+5)^)<<2)  or UInt32((args^.pbuf+4)^ div 64));
    end;
    3: begin
      uy:=(UInt32($3f and (((args^.pbuf+4)^)<<8)) or UInt32((args^.pbuf+7)^ ));
    end;
    4: begin
      uy:=(UInt32(         ((args^.pbuf+6)^)<<6)  or UInt32((args^.pbuf+9)^ div 4));
    end;
    5: begin
      uy:=(UInt32($03 and (((args^.pbuf+9)^)<<12)) or UInt32(((args^.pbuf+8)^)<<4)  or UInt32((args^.pbuf+11)^ div 16));
    end;
    6: begin
      uy:=(UInt32($0f and (((args^.pbuf+11)^)<<10)) or UInt32(((args^.pbuf+10)^)<<2)  or UInt32((args^.pbuf+13)^ div 64));
    end;
    7: begin
      uy:=(UInt32($3f and (((args^.pbuf+13)^)<<8)) or UInt32((args^.pbuf+12)^ ));
      args^.pbuf+=14;
    end;
  end;
  UInt32(Result):=uy;
  args^.bsp+=1;
end;
Who will post the binary?

*

Offline srsa_4c

  • ******
  • 4451
Re: Binary file visualizer
« Reply #3 on: 11 / September / 2016, 10:36:15 »
I've added support for 14 bit raw buffers:
Thx for the contribution. Source and win32 binary (virustotal) attached.


Re: Binary file visualizer (upd. 2018-07-08)
« Reply #4 on: 18 / February / 2024, 11:06:09 »
Slight thread hijack, my apologies, and please move this elsewhere if there's a better place.

I have been working on raw video for modern EOS cams and it involved a lot of messing around trying to work out if a buffer was an image and if so what width and data format.

Attached is my pure python solution.  Should be cross platform (only tested on Linux).

Automatically guesses image width before display.  Attempts to decode from 24 bpp / 8 bit RGB, 16 bpp / 8 bit YUV and 42 bpp / 14 bit Bayer.  Decoding is handled by OpenCV, which supports many formats, should you want to add more.  All the maths stuff is done in numpy so it's fast.

The cool part is the automatic width guessing.  It's a very simple algorithm that I stole from SO.  Because of this, you just give it a buffer and it displays the correct image - most of the time, for me.  Feel free to steal any and all ideas to add them to your code :)

EDIT: example usage (press any key to cycle through displayed image decoding type):
Code: [Select]
./display_buf.py image_buffers/14bit_bayer_02.bin
« Last Edit: 18 / February / 2024, 11:08:51 by names_are_hard »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal