Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:39 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Bitmap colour depth

Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4036
Posted: 10:21pm 02 Sep 2024
Copy link to clipboard 
Print this post

Hey folks,

I don't suppose anyone has a set of .bmp files in the various colour depths supported by MMBasic (black & white, 4-bit, 4-bit compressed, 8-bit colour, 8-bit greyscale, 16-bit and 24-bit) ? I'd like to write a test of this functionality for MMB4L.

Yes, I know I should be able to just find and download this sort of thing from the internet, but I'm finding that much more difficult than I expected.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 07:34am 03 Sep 2024
Copy link to clipboard 
Print this post

Something like this could generate the test images for you.
It is similar to the one by @Sasquatch in another thread but reads back the valid primary colours and saves the BMP.

It should be possible to expand it to also do mixed colours.
'A display colour counter
Clear : Option Base 0
Dim String S$(2) = (" Blues", " Greens", " Reds")
Dim Integer a, b, c, d

For a = 0 To 2 'cycle through blue, green, red
b = 0        'initialize colour count
For c = 0 To 255 'set the brightness
 d = c << (a * 8) 'make a 24bit colour
 Line c+9, 9+50*a, c+9, 45+50*a, 1, d    'send it to a line
 If d = Pixel(c+9, 20+50*a) Then  'read that pixel back from the screen
  Inc b  'if the colour is the same as the one sent count it
  Print d>>16, (d>>8) And 255, d And 255 'Show the RGB values for the matching colour
 EndIf
Next
Print b; S$(a) 'show  counted colours
Next

Save image "colour counter.bmp", 1,1,266,150
End

Edited 2024-09-03 17:45 by phil99
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4036
Posted: 07:43am 03 Sep 2024
Copy link to clipboard 
Print this post

Thanks Phil, but SAVE IMAGE always saves in the 24-bit true colour .bmp format.

I'm looking for images in all the .bmp sub-formats that MMBasic supports.

However I've since found: https://sourceforge.net/projects/bmptestsuite/

Thanks,

Tom
Edited 2024-09-03 17:48 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 07:50am 03 Sep 2024
Copy link to clipboard 
Print this post

  Quote  SAVE IMAGE always saves in the 24-bit true colour .bmp format.

Ok, my mistake I tested on an ILI9431 and the 2040 PicoVGA which are not the same as a 2350.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4036
Posted: 09:48am 03 Sep 2024
Copy link to clipboard 
Print this post

  phil99 said  Ok, my mistake I tested on an ILI9431 and the 2040 PicoVGA which are not the same as a 2350.


I don't have a 2350 ... no distractions until I heave the new alpha for MMB4L over the wall.

But in any case I'm 99% certain the hardware PicoMite/VGA/CMM2 and display is irrelevant (except that display which doesn't support read), the MMBasic SAVE IMAGE command always saves a 24-bit true colour image, even if all the pixels are black.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 10:43am 03 Sep 2024
Copy link to clipboard 
Print this post

  thwill said  Thanks Phil, but SAVE IMAGE always saves in the 24-bit true colour .bmp format.
Tom


Sorry Tom, not true.

If you show an image in mode2 on a PicoMiteVGA, and SAVE IMAGE, you get a BMP files that is 38kbyte size. This is 4bpp.
If you SAVE COMPRESSED IMAGE, you get a BMP file that is (depending the content) few kB...40kB in size. Also in 4bpp.

I use this function, to convert a 24bpp BMP file (created in any package) to a smaller size 4bpp BMP file (like for PETSCII robots). A 320x240 24bpp BMP file is 250kbyte in size.

This is different from LCD. The LCD version saves in 24bpp. Maybe this difference should be added to the PicoMiteVGA user manual, since it is quite essential.

4bpp imgae, and compressed 4bpp image.
flappy.zip

This is the type of image in the zip




Volhout
Edited 2024-09-03 21:10 by Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4036
Posted: 10:54am 03 Sep 2024
Copy link to clipboard 
Print this post

Thanks @Volhout very useful, the manual certainly says the former is saving a 24-bit true colour image, I also wonder if I've been led astray by the CMM2 code or am just "making sh*t up" .

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 11:11am 03 Sep 2024
Copy link to clipboard 
Print this post

  Volhout said  
  thwill said  Thanks Phil, but SAVE IMAGE always saves in the 24-bit true colour .bmp format.
Tom


Sorry Tom, not true.

If you show an image in mode2 on a PicoMiteVGA, and SAVE IMAGE, you get a BMP files that is 38kbyte size. This is 4bpp.
If you SAVE COMPRESSED IMAGE, you get a BMP file that is (depending the content) few kB...40kB in size. Also in 4bpp.

I use this function, to convert a 24bpp BMP file (created in any package) to a smaller size 4bpp BMP file (like for PETSCII robots). A 320x240 24bpp BMP file is 250kbyte in size.

This is different from LCD. The LCD version saves in 24bpp. Maybe this difference should be added to the PicoMiteVGA user manual, since it is quite essential.

4bpp image, and compressed 4bpp image.
flappy.zip

This is the type of image in the zip




Volhout

PicomiteVGA PETSCII ROBOTS
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 12:35pm 03 Sep 2024
Copy link to clipboard 
Print this post

Saving an image from a LCD screen also has the colours reduced to that of the screen.
Eg 24 bits per pixel are sent to an ILI9488 but the saved image has 18 b/P.

The colour counter program shows the 2 LS bits are missing from each colour.

That and the saved images from the PicoMiteVGA is why I thought the 2350 would do the same thing.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4036
Posted: 01:02pm 03 Sep 2024
Copy link to clipboard 
Print this post

  phil99 said  Saving an image from a LCD screen also has the colours reduced to that of the screen.
Eg 24 bits per pixel are sent to an ILI9488 but the saved image has 18 b/P.

The colour counter program shows the 2 LS bits are missing from each colour.

That and the saved images from the PicoMiteVGA is why I thought the 2350 would do the same thing.


I do not believe that there is an 18-bit .bmp standard so suspect what is being saved to the file is 24-bit true colour. I'm guessing that MMBasic (at least on that platform) is only reading and writing 18-bits to the display, you can provide more bits in your RGB but the 2 LS bits are always being discarded. Try using the PIXEL command to plot some "Red" with the 2 LS bits set and then the PIXEL() function to read it back, I wouldn't be surprised if the 2 LS bits are unset in the returned value.

Note that I'm fairly certain that 2350 vs. 2040 has nothing to do with anything; I believe the MMBasic firmware for both is the same in this area.

Best wishes,

Tom
Edited 2024-09-03 23:49 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 06:39pm 03 Sep 2024
Copy link to clipboard 
Print this post

how I did my first sprites pico mmbasic 2 years ago



CONST bk = RGB(BLack)
const wh = rgb(white)
const bl = rgb(blue)
const gr = rgb(green)
const cy = rgb(cyan)
const re = rgb(red)
const ma = rgb(magenta)
const ye = rgb(yellow)
const br = rgb(brown)
'
restore

cls
udg1 'draws sprite1 on screen at 10,10
BLIT READ 1,10,10,16,16 'reads sprite1 from screen to blit buffer1
udg1 'draws sprite2 on screen at 10,10
blit read 2,10,10,16,16 'reads sprite2 from screen to blit buffer2
cls
blit read 3,10,10,16,16 'reads 16x16 background to blit buffer3

sub udg1 'draws 16x16 data for blit to copy
 for spht%=0 to 15
   for spw%=0 to 15
     read sp1%
     pixel spw%+10,spht%+10,sp1%
   next spw%
 next spht%
end sub


'sprite1
data wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh
data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,ye,ye,bk,bk,ye,ye,ye,bk,bk,bk,bk
data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
data bk,ye,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,ye,bk
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bl,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk

it's so basic a way of creating a sprite, if I could add the colours to the abbreviations you'd see the sprite
Edited 2024-09-04 05:03 by stanleyella
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024