{"id":27068307,"url":"https://github.com/a740g/bin2data","last_synced_at":"2026-04-02T15:49:38.363Z","repository":{"id":115303024,"uuid":"597394887","full_name":"a740g/Bin2Data","owner":"a740g","description":"Binary to DATA converter and library for QB64-PE","archived":false,"fork":false,"pushed_at":"2026-03-27T22:56:05.000Z","size":985,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-28T05:12:37.346Z","etag":null,"topics":["base64","base64-decoding","base64-encoding","command-line","commandline-tool","deflate","deflate-compression","library","qb64","qb64-pe","qbasic","quickbasic","retro","zopfli","zopfli-compression"],"latest_commit_sha":null,"homepage":"https://qb64phoenix.com/forum/showthread.php?tid=2228","language":"QuickBASIC","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a740g.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-04T12:18:41.000Z","updated_at":"2026-03-27T22:52:19.000Z","dependencies_parsed_at":"2024-01-13T14:22:20.704Z","dependency_job_id":"fd24a959-4249-4d02-a1fd-4d30ce8fdf3c","html_url":"https://github.com/a740g/Bin2Data","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/a740g/Bin2Data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a740g%2FBin2Data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a740g%2FBin2Data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a740g%2FBin2Data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a740g%2FBin2Data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a740g","download_url":"https://codeload.github.com/a740g/Bin2Data/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a740g%2FBin2Data/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31309378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","base64-decoding","base64-encoding","command-line","commandline-tool","deflate","deflate-compression","library","qb64","qb64-pe","qbasic","quickbasic","retro","zopfli","zopfli-compression"],"created_at":"2025-04-05T20:37:04.329Z","updated_at":"2026-04-02T15:49:38.325Z","avatar_url":"https://github.com/a740g.png","language":"QuickBASIC","readme":"# Bin2Data\n\n`Bin2Data` is a command-line utility, written in [QB64-PE](https://www.qb64phoenix.com), that converts binary files into source code, making it easy to embed resources directly into your executables. It can also optionally compress the data.\n\n![Screenshot](screenshots/screenshot.png)\n\n## Features\n\n* Converts binary files into embeddable source code formats.\n* Optionally compresses data using QB64-PE's `_DEFLATE$` function.\n* Supports multiple output formats:\n  * QB64-PE `DATA` statements (`.bi` file).\n  * QB64-PE `CONST` string (`.bi` file).\n  * C-style header with a `uint8_t` array (`.h` file).\n* Can also output a raw zlib/deflate compressed file (`.deflate`).\n* Base64 encoding for QB64-PE `DATA` and `CONST` formats.\n* Command-line interface with support for wildcards for batch processing.\n\n## Building and Using Bin2Data\n\n### 1. Build from source\n\n1. Clone this repository: `git clone --recurse-submodules https://github.com/a740g/Bin2Data.git`\n2. Change into the directory: `cd Bin2Data`\n3. Open `Bin2Data.bas` in the QB64-PE IDE and press `F5` to compile it.\n\n### 2. Command-Line Usage\n\nYou can run `Bin2Data` from your terminal. The help screen shows the available options.\n\n```text\nBin2Data: Converts binary files to QB64-PE data\nCopyright (c) 2026 Samuel Gomes\nhttps://github.com/a740g\n\nUsage: Bin2Data [-w characters_per_data_line] [-i compression_level] [-d] [-c] [-p] [-r] [-s] [-o] [filespec]\n   -w: A number specifying the number of characters per data line. 8-4096 (default 112)\n   -i: A number specifying the compression level. 1-10\n   -d: Generate DATA (.bi; default)\n   -c: Generate a CONST (.bi; suitable for small files)\n   -p: Generate a C array (.h)\n   -r: Dump the raw compressed file (.deflate)\n   -s: Disable compression and store the file instead\n   -o: Overwrite output file if it exists\n\nNote:\n * Will create filespec.bi/.h/.deflate (based on the switches)\n * Can bulk convert files using wildcards\n * filespec can be a URL\n * If filespec.bi/.h/.deflate exists, then it will not be overwritten (unless -o is specified)\n * Character per line may be changed in CONST mode due to QB64's 500 line continuation limit\n * C output is barebones. Use sizeof to get the array size\n```\n\n## Using the Generated Files\n\n### QB64-PE Projects\n\nFor QB64-PE, you need `Resource/Resource.bi` from the [Toolbox64](https://github.com/a740g/Toolbox64) library.\n\n#### Example: Using DATA statements (`-d` switch)\n\nThis is the default mode. It creates a `.bi` file containing a `RESTORE` label and `DATA` statements.\n\n1. Generate the file: `Bin2Data my_asset.png`\n    This will create `my_asset.png.bi`.\n\n2. In your main QB64-PE program:\n\n```vb\n' Include the library implementation (assuming you have cloned Toolbox64 in the include directory under your project directory)\n'$INCLUDE:'include/Resource/Resource.bi'\n\n' Include the generated data file\n'$INCLUDE:'my_asset.png.bi'\n\n' Load the resource.\n' The label name is generated based on the filename and size.\n' You can find the exact label name in the generated .bi file.\nRESTORE data_my_asset_png_bi_12345 \nDIM buffer AS STRING\nbuffer = Resource_LoadBase64Data\n\n' Now 'buffer' contains the binary data of my_asset.png\n' ...\n```\n\n#### Example: Using a CONST string (`-c` switch)\n\nThis mode is suitable for smaller files. It creates a `.bi` file containing `CONST` definitions.\n\n1. Generate the file: `Bin2Data -c my_icon.ico`\n    This will create `my_icon.ico.bi`.\n\n2. In your main QB64-PE program:\n\n```vb\n' Include the library implementation (assuming you have cloned Toolbox64 in the include directory under your project directory)\n'$INCLUDE:'include/Resource/Resource.bi'\n\n' Include the generated constants file\n'$INCLUDE:'my_icon.ico.bi'\n\n' Load the resource using the generated CONSTs.\n' The CONST names are based on the filename and size.\n' Check the generated .bi file for the exact names.\nDIM buffer AS STRING\nbuffer = Resource_LoadBase64String(DATA_MY_ICON_ICO_BI_123, SIZE_MY_ICON_ICO_BI_123, COMP_MY_ICON_ICO_BI_123)\n\n' Now 'buffer' contains the binary data of my_icon.ico\n' ...\n```\n\n### C/C++ Projects\n\nWhen using the `-p` switch, `Bin2Data` generates a C header file (`.h`).\n\n1. Generate the file: `Bin2Data -p my_data.bin`\n    This will create `my_data.bin.h`.\n\n2. In your C/C++ code:\n\n```c\n#include \"my_data.bin.h\"\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n\nint main() {\n    // The header defines symbols based on the filename and size, for example:\n    // - const uint8_t my_data_bin_h_567[] = {...}; (the data array)\n    // - #define SIZE_MY_DATA_BIN_H_567() 567       (original size)\n    // - #define COMP_MY_DATA_BIN_H_567() 1         (is compressed)\n    // - #define DATA_MY_DATA_BIN_H_567() ...       (pointer to data)\n    \n    // Note: If the data is compressed (COMP_...() is 1),\n    // you will need a zlib/deflate library to decompress it.\n    \n    size_t dataSize = sizeof(my_data_bin_h_567);\n    \n    printf(\"Original size: %d\\n\", SIZE_MY_DATA_BIN_H_567());\n    printf(\"Embedded size: %zu\\n\", dataSize);\n    printf(\"Is compressed: %d\\n\", COMP_MY_DATA_BIN_H_567());\n\n    // You can now use the my_data_bin_h_567 array.\n    \n    return 0;\n}\n```\n\n## Notes\n\n* This tool requires a [recent version](https://github.com/QB64-Phoenix-Edition/QB64pe/releases/latest) of [QB64-PE](https://www.qb64phoenix.com) to build.\n* When you clone a repository that contains submodules, you need to run `git submodule update --init --recursive` to fetch the submodule content.\n\n## Assets\n\n* [Icon](https://www.iconarchive.com/artist/umut-pulat.html) by [Umut Pulat](http://12m3.deviantart.com/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa740g%2Fbin2data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa740g%2Fbin2data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa740g%2Fbin2data/lists"}