Richard I know you have had lots of experience with color.(or Colour)
If say, you had to extract pixels in their original color from an image (say a picture of Mars) in 24 bit BMP image format,
would you just use the TINT extraction, and if you did, how could you keep the pixel information small if you stored it?
(lets say you were making your own custom image storage format)
In other words is there a way to compact the TINT information to say a shorter hex number?
24 bit BMP image color question
-
- Posts: 101
- Joined: Sat 23 Jun 2018, 19:52
24 bit BMP image color question
Focus is on code subject. Feel free to judge the quality of my work.
Re: 24 bit BMP image color question
Notwithstanding your confessed desire to reinvent the wheel (!), there's no way you (or I) could devise an image compression scheme better than the standard ones, such as PNG (which is lossless compression) or JPG (which is lossy compression) or even JPEG2000 (which has both lossless and lossy profiles).
So I would use a standard image compression utility, of which there are dozens. You could do it in BBC BASIC (e.g. by using GDI+ in BBC BASIC for Windows or libpng in BBC BASIC for SDL 2.0) but there's very little point. The only times I have done that are when I've needed more control over the conversion than the standard utilities provide, such as setting the 'alpha channel' (transparency) explicitly, or using a less-common format (such as 48 bits-per-pixel).
To keep this relevant to BBC BASIC, can I remind you (and everybody) that POINT and TINT are horrendously slow in BBCSDL, so should almost always be avoided if possible.
-
- Posts: 101
- Joined: Sat 23 Jun 2018, 19:52
Re: 24 bit BMP image color question
Thanks Richard.
I knew it was probably better to ask first before I attempted to compress even small 24bit BMP images into code.
The objective was to say, be able to take a small image and include it in a short news article for space news on the Web version of BBCSDL.
Keeping everything within the program would allow 1 link to 1 file. ( and I remember your suggestion about ( tyboob_loader.bbc )
The long line of attempts at image to code tools including the latest 16 color PROCbmptocode(name$,width,height) encoder *
which works, attempts to allow me to insert my images within my program as code. (small images only)
So it is a success and I think I am the only person that has done that. (maybe I am wrong)
This has also been tested on the Web version of BBCSDL -
I knew it was probably better to ask first before I attempted to compress even small 24bit BMP images into code.
The objective was to say, be able to take a small image and include it in a short news article for space news on the Web version of BBCSDL.
Keeping everything within the program would allow 1 link to 1 file. ( and I remember your suggestion about ( tyboob_loader.bbc )
The long line of attempts at image to code tools including the latest 16 color PROCbmptocode(name$,width,height) encoder *
which works, attempts to allow me to insert my images within my program as code. (small images only)
So it is a success and I think I am the only person that has done that. (maybe I am wrong)
This has also been tested on the Web version of BBCSDL -
Focus is on code subject. Feel free to judge the quality of my work.
Re: 24 bit BMP image color question
If you particularly want to include images (and/or music etc.) within a program I would suggest that, once again, you adopt a standard, in this case the Base64 encoding used e.g. for email attachments. You could incorporate Base64-encoded .png, .jpg or .mp3 files in a program as DATA statements.
Encoding or decoding Base64 in BASIC is not difficult, there are examples at the Wiki here and here.