{"id":13344418,"url":"https://github.com/stefanbylund/zxnext_bmp_tools","last_synced_at":"2025-03-12T07:33:10.877Z","repository":{"id":230231752,"uuid":"110260248","full_name":"stefanbylund/zxnext_bmp_tools","owner":"stefanbylund","description":"Spectrum Next BMP tools","archived":false,"fork":false,"pushed_at":"2024-06-07T11:52:03.000Z","size":698,"stargazers_count":25,"open_issues_count":0,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-07-30T21:10:05.677Z","etag":null,"topics":["bmp","c","image-processing","sinclair","spectrum-next","zx-spectrum"],"latest_commit_sha":null,"homepage":null,"language":"C","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/stefanbylund.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2017-11-10T15:10:07.000Z","updated_at":"2024-07-23T07:25:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"383e8ced-b90b-4465-be6f-fb82bc5f71aa","html_url":"https://github.com/stefanbylund/zxnext_bmp_tools","commit_stats":null,"previous_names":["stefanbylund/zxnext_bmp_tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbylund%2Fzxnext_bmp_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbylund%2Fzxnext_bmp_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbylund%2Fzxnext_bmp_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbylund%2Fzxnext_bmp_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanbylund","download_url":"https://codeload.github.com/stefanbylund/zxnext_bmp_tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221279967,"owners_count":16790562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bmp","c","image-processing","sinclair","spectrum-next","zx-spectrum"],"created_at":"2024-07-29T19:33:08.920Z","updated_at":"2024-10-24T05:30:35.768Z","avatar_url":"https://github.com/stefanbylund.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next BMP Tools\n\nThe **Next BMP tools** are BMP image conversion tools targetting ZX Spectrum\nNext. These tools are used for converting the palette of 8-bit BMP files to\nSpectrum Next format and converting such 8-bit BMP files to raw image files\nsuitable for layer 2 and sprite graphics on Spectrum Next. The tools are\ndescribed in more detail below.\n\nThe Next BMP tools are inspired by Jim Bagley's BMPtoNext and NextGrab tools but\nwith added support for the Spectrum Next RGB333 palette and with more validations\nand options.\n\n## Download\n\nThe latest version of the Next BMP tools can be downloaded\n**[HERE](https://github.com/stefanbylund/zxnext_bmp_tools/blob/master/build/zxnext_bmp_tools.zip)**.\nThis download contains prebuilt executables for Windows along with the source\ncode and this README.md file. If you want to build the Next BMP tools yourself,\nsee the \"How to Build\" section below.\n\n## How to Use\n\nBelow are descriptions of the nextbmp and nextraw tools and information on how\nto use them.\n\n### nextbmp\n\nTool for converting the palette in an uncompressed 8-bit BMP file to Spectrum\nNext format. The original RGB888 colors in the palette are converted to RGB333\ncolors and then back to their equivalent RGB888 colors. The resulting RGB888\ncolors are equivalent representations of the Spectrum Next RGB333 colors and\nthe converted BMP file should display exactly as when rendered natively on the\nSpectrum Next (disregarding color calibration of the monitors being used).\nIf no destination BMP file is specified, the source BMP file is modified.\nRun the nextbmp tool without any parameters to get a list of all options.\n\nTip: If you have an image in another format than BMP (e.g. PNG) or another color\ndepth than 8 bits/pixel (e.g. 24-bit BMP), first convert the image to an 8-bit\nBMP image in a paint program (e.g. Adobe Photoshop, Paint.NET, GIMP or PaintShop\nPro) before converting it to Spectrum Next palette format using the nextbmp tool.\n\nTip: The [palettes](palettes) directory contains Spectrum Next palette files in\nseveral common palette formats for use with many paint programs. This directory\nalso contains a palette in [256](palettes/zxnext-artistic-palette-256.png) and\n[512](palettes/zxnext-artistic-palette-512.png) colors designed for graphics\nartists.\n\nTip: [Color Quantizer](http://x128.ho.ua/color-quantizer.html) is an excellent\nimage processing tool for downscaling the number of colors in an image. Use it\ntogether with the 512 color Spectrum Next palette file\n[zxnext-palette-512.pal](palettes/zxnext-palette-512.pal) for best results.\n\nNote that when the original RGB888 colors in the palette are converted to RGB333\ncolors, the resulting 3-bit color components may not end up as integers and must\nbe rounded to an integer (0 - 7). By default, the 3-bit color components are\nrounded to the nearest integer (-round). However, depending on the original\nRGB888 colors, this may not always be the best choice. Sometimes, better results\nare achieved by rounding upwards (-ceil) or downwards (-floor).\n\nIf the -min-palette option is specified, the converted palette is minimized\nby removing any duplicated colors, sorting it in ascending order (i.e. the\nsame order as in the Spectrum Next standard palette), and clearing any unused\npalette entries at the end. This is useful if you convert images that you\nhave not created the palette for and which may end up having duplicated\npalette colors when being converted. This option is ignored if the\n-std-palette option is given.\n\nIf the -std-palette option is specified, the original RGB888 colors in the\npalette are converted to the Spectrum Next standard palette RGB332 colors\n(which are extended to RGB333 colors when displayed). This is useful if you need\nto use the standard palette. However, better results are generally achieved when\nconverting to the closest matching RGB333 colors. This option is ignored if the\n-4bit option is given.\n\nIf the -4bit option is specified, the first 16 unique colors in the palette\nwill be moved to the start of the palette and all other palette entries\nwill be cleared. Any pixels in the image referencing any of the discarded\ncolors will also be cleared. The result will be a 4-bit image saved as an\n8-bit BMP file. Use this option for images intended to be displayed in the\n640 x 256 layer 2 mode or for 4-bit sprite sheets.\n\nNote: The BMP file format supports both 4 and 8 bits per pixel. However, most\nmodern paint programs only support 8 bits per pixel as the lowest color depth\nwhen saving to a BMP file. Therefore, nextbmp assumes that a 16 color 4-bit\nimage is contained in an 8-bit BMP file and not a 4-bit BMP file. If you would\nhave an actual 4-bit BMP file, you must first save it as an 8-bit BMP file in\nyour paint program before using it with the nextbmp tool and its -4bit option.\n\n**Examples:**\n```\n\u003e nextbmp image.bmp\n\u003e nextbmp -ceil -min-palette image.bmp image2.bmp\n\u003e nextbmp -floor -std-palette image.bmp image2.bmp\n\u003e nextbmp -4bit image.bmp image2.bmp\n```\n\nThe first example will convert the palette in the BMP file image.bmp.\n\nThe second example will convert the palette in the BMP file image.bmp and write\nit to the new BMP file image2.bmp and round up the color values to the nearest\ninteger when converting the palette. The converted palette will be minimized by\nremoving any duplicated colors.\n\nThe third example will convert the palette in the BMP file image.bmp to the\nSpectrum Next standard palette and write it to the new BMP file image2.bmp and\nround down the color values to the nearest integer when converting the pixel\ncolors.\n\nThe fourth example will convert the palette in the BMP file image.bmp to 16\ncolors and write it to the new BMP file image2.bmp. This is suitable for\n640 x 256 layer 2 graphics and 4-bit sprite sheets.\n\nThe table below shows how the values for the RGB332 2-bit blue color component\nand RGB333/RGB332 3-bit red/green/blue color components are mapped to RGB888\n8-bit red/green/blue color components:\n\n| 2-bit | 3-bit | 8-bit |\n|------:|------:|------:|\n|   0   |   0   |    0  |\n|       |   1   |   36  |\n|       |   2   |   73  |\n|   1   |   3   |  109  |\n|       |   4   |  146  |\n|   2   |   5   |  182  |\n|       |   6   |  219  |\n|   3   |   7   |  255  |\n\n### nextraw\n\nTool for converting an uncompressed 8-bit BMP file to a raw image file for\nSpectrum Next. The RGB888 colors in the BMP palette are converted to RGB333\ncolors. If no destination file for the raw image is specified, the same name as\nthe source BMP file is used but with the extension \".nxi\". If the -sep-palette\noption is specified, the raw palette is written to a separate file with the\nsame name as the raw image file but with the extension \".nxp\", otherwise it is\nprepended to the raw image file. If the -no-palette option is specified, no raw\npalette is created, e.g. if the BMP file uses the Spectrum Next standard palette\nthere is no need to create the raw palette. Run the nextraw tool without any\nparameters to get a list of all options.\n\nNote: If the BMP file does not already contain an RGB888 palette representing\nthe Spectrum Next RGB333 colors, first convert the BMP file to Spectrum Next\nformat using the nextbmp tool.\n\nIf the -4bit option is specified, each pixel is 4 bits so that each byte in\nthe raw image data will contain two horizontally adjacent pixels (where the\n4 highest bits contain the leftmost pixel and the 4 lowest bits contain the\nrightmost pixel) and the palette will contain 16 colors. By default, each\npixel is 8 bits so that each byte in the raw image data will contain one\npixel and the palette will contain 256 colors. Use this option for images\nintended to be displayed in the 640 x 256 layer 2 mode or for 4-bit sprite\nsheets.\n\nIf the -columns option is specified, the raw image data will consist of\npixels in linear order from top-to-bottom and left-to-right, i.e. columns of\npixels from left to right. By default, the raw image data will consist of\npixels in linear order from left-to-right and top-to-bottom, i.e. rows of\npixels from top to bottom. Use this option for images intended to be\ndisplayed in the 320 x 256 or 640 x 256 layer 2 mode.\n\nBy default, the raw image file contains the raw palette followed by the raw\nimage data. If the -sep-palette option is specified, the raw palette is\ninstead written to a separate file. By default, the raw palette consists of\n256 RGB333 colors and is 512 bytes long. If the -4bit option is specified,\nthe raw palette consists of 16 RGB333 colors and is 32 bytes long. The RGB333\ncolors are stored as an RGB332 byte followed by a zero-extended byte\ncontaining the lowest blue bit. By default, the raw image data consists of\nlinear rows of pixels from top to bottom. If the -columns option is specified,\nthe raw image data consists of linear columns of pixels from left to right.\nThe 4/8-bit pixels are indexes into the 16/256 color palette.\n\n**Examples:**\n```\n\u003e nextraw image.bmp\n\u003e nextraw -sep-palette image.bmp graphics.nxi\n\u003e nextraw -no-palette image.bmp graphics.nxi\n\u003e nextraw -4bit sprites.bmp\n\u003e nextraw -columns wide.bmp\n\u003e nextraw -columns -4bit hires.bmp\n```\n\nThe first example will convert the BMP file image.bmp to a raw image file\ncontaining 256 x 192 layer 2 graphics or an 8-bit sprite sheet. By default the\nraw image file will get the name image.nxi and have the raw palette prepended\nto it.\n\nThe second example will convert the BMP file image.bmp to the raw image file\ngraphics.nxi and write the raw palette to a separate file called graphics.nxp.\n\nThe third example will convert the BMP file image.bmp to the raw image file\ngraphics.nxi and don't create any raw palette.\n\nThe fourth example will convert the BMP file sprites.bmp to a raw image file\ncontaining a 4-bit sprite sheet.\n\nThe fifth example will convert the BMP file wide.bmp to a raw image file\ncontaining 320 x 256 layer 2 graphics.\n\nThe sixth example will convert the BMP file hires.bmp to a raw image file\ncontaining 640 x 256 layer 2 graphics.\n\n## How to Build\n\nThe Next BMP tools are written in portable C code and should compile and run on\nany modern operating system with a C compiler supporting C99 (or actually a\nquite small subset thereof). The tools have been successfully compiled with GCC\nand Microsoft Visual Studio and has been verified on Windows and Linux. They\nshould also work on macOS but that has not yet been tested.\n\nUse the following command-lines to build using GCC (add -std=c99 if you're using\nan older version of GCC):\n```\n\u003e gcc -O2 -Wall -o nextbmp nextbmp.c -lm\n\u003e gcc -O2 -Wall -o nextraw nextraw.c -lm\n```\n\nUse the following command-lines to build using Microsoft Visual Studio:\n```\n\u003e cl /O2 /W2 nextbmp.c\n\u003e cl /O2 /W2 nextraw.c\n```\n\nNote that you don't need to use Microsoft Visual Studio when compiling on\nWindows, you can also use [MinGW GCC](http://www.mingw.org/).\n\n## License\n\nThis software is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanbylund%2Fzxnext_bmp_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanbylund%2Fzxnext_bmp_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanbylund%2Fzxnext_bmp_tools/lists"}