Tool for converting image to binary form for storing in FPGA - Page 1
Forum section: electronics / general

author: davorin
author_rank: Unknown
timestamp: April 28, 2018, 03:02:08 pm
content: EHLO (o;Does someone know of a tool or script which can take a PNG/TIFF/whatever RGB image and convert it to a raw binary data representation for converting then to Intel HEX format which Altera Quartus accepts?This is for testing my Verilog RGB panel driver design....

author: Siwastaja
author_rank: Super Contributor
timestamp: April 28, 2018, 04:15:08 pm
content: GIMP can save a headerless RAW, just type in extension .data when saving. RGBRGB... and RRRBBBGGG formats are supported. Then, you only need to convert it to Intel HEX.

author: janoc
author_rank: Super Contributor
timestamp: April 28, 2018, 04:20:58 pm
content: ImageMagickhttps://www.imagemagick.org/script/index.phpEasier to script/integrate into a build system.

author: davorin
author_rank: Unknown
timestamp: April 28, 2018, 04:24:56 pm
content: Tried ImageMagick withconvert icon.png icon.rgbbut output file seemed rubbish....thought convert recognizes input/output formats automatically.The filesize was exact though for a 64x64 rgb image..

author: Wiljan
author_rank: Regular Contributor
timestamp: April 28, 2018, 05:17:00 pm
content: Irfanview does save as RAW with different options

author: chris_leyson
author_rank: Super Contributor
timestamp: April 28, 2018, 05:32:33 pm
content: Matlab or GNU Octave will do it.

author: janoc
author_rank: Super Contributor
timestamp: April 28, 2018, 06:05:58 pm
content: Quote from: davorin on April 28, 2018, 04:24:56 pmUse the .raw extension instead and the "stream" tool:stream input.png output.raw

author: hamster_nz
author_rank: Super Contributor
timestamp: April 28, 2018, 08:00:13 pm
content: Being old-school I save in PMN format, then use a short program, that can use the attributes in the human readable ASCII header.

author: @rt
author_rank: Super Contributor
timestamp: April 29, 2018, 06:59:14 am
content: Singe it’s an RGB panel, is there a reason not to use MSPaint to open the file, save as 24 bit MS bitmap, and then manually strip the header with a hex editor?

author: davorin
author_rank: Unknown
timestamp: April 29, 2018, 07:04:52 am
content: Ah I see what the problem is...nothing to do with rgb conversion (o;Did a small 64x64 rgb png with just a red dot on black backrground...The generated hex file is correct and shows that the first occurrence of rad is at address 0x07CE (28):Code::2007C00000000000000000000000000000002800005F00008F0000B90000DA0000F100007FThe used memory is organized as 24x4096...and when looking with the in-system memory controller....the same pattern appears at 24-bit word address:So seems quartus messes up with the hex file when the memory is not organized as 8-bit wide..

author: davorin
author_rank: Unknown
timestamp: April 29, 2018, 07:50:11 am
content: Seems there are no tools which can generate a 24-bit wide memory initialization file....srec_cat supports mif files, but only with widths being a multiple of 8 like:Code:srec_cat icon.rgb -binary -output icon.mif -mif 1srec_cat icon.rgb -binary -output icon.mif -mif 2srec_cat icon.rgb -binary -output icon.mif -mif 4Seems I have to split the rgb channels in 3 8-bit wide memories.This are the commands used for generating 3 memory initialization files for Quartus:Code:convert image.png -separate image_%d.graysrec_cat image_0.gray -binary -output image_0.mif -mifsrec_cat image_1.gray -binary -output image_1.mif -mifsrec_cat image_2.gray -binary -output image_2.mif -mif