Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:57 31 Jul 2025 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 : Do we have a PicoMiteVGA image editor ?

     Page 2 of 2    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10305
Posted: 11:09am 08 Jun 2025
Copy link to clipboard 
Print this post

The HDMI version of the PicoMite has massive advantages over VGA especially for this sort of thing - full colour support, or stay with 16 colour but pick any 16 from 65536 using the map capability. If there were to be a simplification my vote would go for just 3, the RP2350 PicoMite, RP2350 WebMite + RP2350 HDMIUSB.
The RP2350 is completely software compatible with the RP2040, is faster, has more memory, has a better ADC and MMBasic circumvents E9. It would certainly make my life easier.
I will probably stop RP2040 development after 6.00.02. I've then got some fun ideas for the RP2350 PicoMite using a proper in-memory framebuffer and with the 2nd CPU updating the physical display in the background. I've played with this already and can get 50Hz full screen refresh rates on a SPI ILI9341. Stick a RP2350 onto the Game*Mite with this support and the opportunities are endless
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 11:24am 08 Jun 2025
Copy link to clipboard 
Print this post

Spun off https://www.thebackshed.com/forum/ViewTopic.php?PID=240499 in the hopes of avoiding further platform discussion in this thread - sorry, I probably started it.

Tom
Edited 2025-06-08 21:24 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1232
Posted: 12:31pm 08 Jun 2025
Copy link to clipboard 
Print this post

  matherp said  The HDMI version of the PicoMite has massive advantages over VGA especially for this sort of thing - full colour support, or stay with 16 colour but pick any 16 from 65536 using the map capability.

This is useful because the MAP command can also be used to display gray and brown tones. This does not change the file size. Unfortunately, this would also leave out many VGA users, which in my opinion would severely limit the distribution and acceptance of the program. One solution would be to use 2 graphics packages, one for VGA and one for HDMI.
But let's let Tom write the game first.  

Have you adjusted the load image routine so that it takes the colors from a 4-bit BMP correctly for HDMI?
Cheers
Martin
'no comment
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 665
Posted: 12:38pm 08 Jun 2025
Copy link to clipboard 
Print this post

  thwill said  
  Amnesie said  do you mean something like Paint?

Look here: https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=17589


Thanks Daniel, that is what I meant.

In that post you showed an illustration from a PicoMite(VGA?) that had been modified to allow grey in the palette though you never posted a schematic ?



Sorry, here is the schematic:


Schematic_gainta_2025-06-08.pdf



Greetings
Daniel
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 05:53am 09 Jun 2025
Copy link to clipboard 
Print this post

  Martin said  This is useful because the MAP command can also be used to display gray and brown tones. This does not change the file size. Unfortunately, this would also leave out many VGA users, which in my opinion would severely limit the distribution and acceptance of the program. One solution would be to use 2 graphics packages, one for VGA and one for HDMI.

I feel that the colour depth on the VGA is not great enough. If the images could be made suitable for the Pico HDMI, MMB4W, MMB4L and the CMM2 that would reach a wider audience. It's Tom's baby of course but I would choose that option with a view to later down grading the colour depth to suit the VGA version.

Who knows, there may be a 2350 VGA with greater colour depth in our future?

Speaking of an audience, how many members have actually used SAAINT to any extent? Not too many have tried it and persisted with any adventure I expect.

Bill
Keep safe. Live long and prosper.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2638
Posted: 08:30am 09 Jun 2025
Copy link to clipboard 
Print this post

  Quote  Who knows, there may be a 2350 VGA with greater colour depth in our future?
If the same number of pins used by the HDMI version are allocated to VGA the images would be better. However memory usage would increase and any extra processing time would have to fit in the refresh rate.

Assuming firmware support is practical, the existing 4 colour pins could have a selection of plugin resistor modules for different palettes. For Images matching codecs would be needed.

If firmware support isn't viable it can be done in Basic and pre-processing for images but it is a bit clumsy.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7933
Posted: 08:57am 09 Jun 2025
Copy link to clipboard 
Print this post

HDMI uses only two more pins than RGB121. You could, potentially, use RGB222 VGA for the same number of pins but that's still only 64 colours and you don't get the benefit of the HSTX to push the data out faster. Of course, the frame buffer is bigger to make space for the extra colour bits. So there is more data to move.

IMHO there is nothing to be gained by using VGA now other than the fact that the connector is easier to solder. If you accept that both RP2350 VGA and (poor) HDMI displays handle a maximum resolution of 640x480 then HDMI still wins hands down as the 16 available colours are mapped from RGB555 and you get the HSTX speed.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 633
Posted: 10:41am 09 Jun 2025
Copy link to clipboard 
Print this post

Or simply use a very cheap, self powered HDMI to VGA dongle. Then you have all the advantages of MMBasic HDMI but on a VGA screen, with no rewiring and full MMBasic support?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7933
Posted: 11:21am 09 Jun 2025
Copy link to clipboard 
Print this post

I used one when I got my first Raspberry Pi. :)  That monitor had VGA and DVI sockets.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 05:40pm 01 Jul 2025
Copy link to clipboard 
Print this post

Martin, what software are you using to achieve your dithered images using the RGB121 palette ?

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1232
Posted: 06:12pm 01 Jul 2025
Copy link to clipboard 
Print this post

  thwill said  Martin, what software are you using to achieve your dithered images using the RGB121 palette ?

Tom

I use “ditherit.com" for dithering.
But the image I posted was a mixture of dithering and a simple customization of an image in MM-Basic 4 Windows:
'ForPico.bas
'MMB4W Modes etc. Loads a source PNG and translatet ist to 121 RGB BMP
'Source Filename,width and height here
FN$="source":W=124:H=240
'---------------------------------
mode 1:'(MMB4W Mode)
load png FN$+".png"
for y=0 to h
for x=0 to w
cl%=0
n=Pixel(x,y)AND &HFFFFFF
'-->get Red
r=n AND &HFF
if r>96 and r<128 then
if (y mod 2)then
R=255*(x mod 2)
else
R=255*not (x mod 2)
endif
end if
inc cl%,255*(r>127):n=int(n/256)

'-->get Green
g=n AND &HFF
select case g
case >191
inc cl%,&HFF00
goto weiter
case >127
inc cl%,&H8000
goto weiter
case >63
inc cl%,&H4000
end select
weiter:

'-->get Blue
n=int(n/256)
b=n AND &HFF
inc cl%,&Hff0000*(b>64)
pixel x,y,cl%
next
next
save image FN$+".bmp",0,0,w,h
In the program, you can adjust the threshold values as required to obtain a useful result.
I then merged both images into one using Paint.net, i.e. I took the parts I liked better from the respective version.(An alternative to Paint.net is Pinta, designed for Linux and Mac,)
Edited 2025-07-02 04:37 by Martin H.
'no comment
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 08:34am 02 Jul 2025
Copy link to clipboard 
Print this post

Thanks again Martin.

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 01:57am 09 Jul 2025
Copy link to clipboard 
Print this post

Hi Martin,

I'm trying to use AI to generate some images for Tom. The nearest AI can get to 240x160 is 1536x1024 which I can easily reduce using  MS Paint.

I changed the image size in the program to:

FN$="source":W=240:H=160


and it worked well. Thank you Martin.

I tried using the original size of 1536x1024 but got an error message "Image too large". Time to RTFM. The manual says that mode 16 will do 1920x1080 so I made that change to the program.

mode 16:'(MMB4W Mode)

(The colon is redundant)

The result was that a message flashed up on the screen and disappeared too quickly for me to read and left a blank screen in it's wake.

AI does not seem to like to use only the colours I want (to suit the Pico VGA palette). I need to generate an image, convert the colours using the above program, correct the original and repeat until I get a useful image. I would prefer to use the original file size if possible as it would remove one step from the process and, I suspect, produce a better end result.

If anyone does know if MMB4W can LOAD a PNG image of 1536x1024 and point out my stupid mistake I would be very grateful.

Bill
Keep safe. Live long and prosper.
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1232
Posted: 07:51am 15 Jul 2025
Copy link to clipboard 
Print this post

I was not asked but I have adjusted the program again, now blue and red are hatched depending on the threshold value (0-255). The values can be adjusted of the thresholds depending on the source image.
'MMB4W Modes etc. Loads a source PNG and translatet ist to 121 RGB BMP
'---------------------------------
'Source Filename,width and height here
FN$="kingtut":W=320:H=200
'thresholds (0-255) (Should be customized to the source)
LR=96 'Lower threshold Red
UR=128 'Upper threshold

LG=63 'Lower threshold Green
MG=127 'Mid threshold
UG=160 'Upper threshold

LB=64 'Lower threshold Blue
UB=162 'Upper threshold
'---------------------------------
mode 1
load png FN$+".png"
for y=0 to h
   for x=0 to w
       cl%=0
       n=Pixel(x,y)AND &HFFFFFF
       '-->get Red
       r=n AND &HFF
'Check red thresholds if value is in then dither
       if r>LR and r<UR then
        if (y mod 2)then
        R=255*(x mod 2)
        else
        R=255*not (x mod 2)
        endif
       end if
       inc cl%,255*(r>127):n=int(n/256)
       '-->get Green
       g=n AND &HFF
'Check green thresholds, no dithering
       select case g
       case >UG
       inc cl%,&HFF00
       case >MG
       inc cl%,&H8000
       case >LG
       inc cl%,&H4000
       end select
       '-->get Blue
       n=int(n/256)
       b=n AND &HFF
'Check Blue thresholds, if value is in then dither
if B>64 and b<162 then
        if (y mod 2)then
        B=255*(x mod 2)
        else
        B=255*not (x mod 2)
        endif
       end if
       inc cl%,&Hff0000*(b>64)
       pixel x,y,cl%
   next
next
save image FN$+".bmp",0,0,w,h

An example:


Edited 2025-07-15 19:40 by Martin H.
'no comment
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 08:31pm 16 Jul 2025
Copy link to clipboard 
Print this post

Many thanks again Martin.

I noticed that you did not include a form of dithering for blue in your original program and added it myself following your example with the red colour. Since then I have decided to use solid colours where I can and use your program at an image resolution of 1024x682. This is because AI (ChatGPT and Copilot) cannot produce images without anti-aliasing and using your program at the higher resolution reduces the number of stray pixels this causes.

AI also cannot stick to the colours I need even when I give it the Hex codes for them. This why your program has been invaluable to me.

Bill

PS My stupid mistake was that MMB4W mode 16 is for wide screen monitors which my laptop does not have.  
Keep safe. Live long and prosper.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 05:01am 17 Jul 2025
Copy link to clipboard 
Print this post

Martin, Are these changes in RED correct?

'Check red thresholds if value is in then dither
      if r>LR and r<UR then
       if (y mod 2)then
       R=255*(x mod 2)
       else
       R=255*not (x mod 2)
       endif
      end if
      inc cl%,255*(r>UR):n=int(n/256)


'Check Blue thresholds, if value is in then dither
if B>LB and b<UB then
       if (y mod 2)then
       B=255*(x mod 2)
       else
       B=255*not (x mod 2)
       endif
      end if
      inc cl%,&Hff0000*(b>LB)
      pixel x,y,cl%


Bill
Keep safe. Live long and prosper.
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1232
Posted: 07:58am 17 Jul 2025
Copy link to clipboard 
Print this post

Hello Bill,
well recognized. The query below is actually only for checking whether a value has been set or not, i.e. on or off, because there are only 2 states for blue and red.I have rotated the logic of the dithering for red once, so that blue and red write more or less in the gaps (if any) of the other color. How you query this doesn't really make a difference  
I have rotated the logic of the dithering for red once, so that blue and red write more or less in the gaps (if any) of the other color. I can't really say whether this is better or not

      '-->get Red
       r=n AND &HFF
       'Check red thresholds if value is in then dither
       if r>LR and r<UR then
        if (y mod 2)then
        R=255*not (x mod 2)
        else
        R=255*(x mod 2)
        endif
       end if
       inc cl%,255*(r>127):n=int(n/256)


Here you can test the threshold values of the individual colors


Pico:



the values used
'Source Filename,width and height here
FN$="colors":W=225:H=225
'thresholds (Should be customized to the source)
LR=85 'Lower threshold Red
UR=170   'Upper threshold

LG=64 'Lower threshold Green
MG=128 'Mid threshold
UG=192 'Upper threshold

LB=85 'Lower threshold Blue
UB=170 'Upper threshold
'---------------------------------

Edited 2025-07-18 15:37 by Martin H.
'no comment
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1232
Posted: 09:22am 20 Jul 2025
Copy link to clipboard 
Print this post

I asked Copilot how to read the Picturesize out of a png file.
This means that it is no longer necessary to enter the width and height manually.
it is sufficient to enter the file name in FN$ (without extension) to convert the image to RGB121 BMP. Now “only” a Gui is missing with which you can change the threshold values.
'MMB4W Modes etc. Loads a source PNG and translatet it to 121 RGB BMP
'---------------------------------
'Source Filename,width and height here
FN$="kingtut"
'thresholds (Should be customized to the source)
LR=85   'Lower threshold Red
UR=170   'Upper threshold

LG=64   'Lower threshold Green
MG=128  'Mid threshold
UG=192  'Upper threshold

LB=85   'Lower threshold Blue
UB=170  'Upper threshold
'---------------------------------
dim w, h

open FN$ + ".png" for input as #1
s$ = INPUT$(24, #1) ' Get first 24 bytes (up to end of IHDR header)

' Width from byte 17-20 (Index 16–19 in MMBasic)
w = ASC(MID$(s$,17,1))*16777216 + ASC(MID$(s$,18,1))*65536 + ASC(MID$(s$,19,1))*256 + ASC(MID$(s$,20,1))

' Height from byte 21-24 (index 20-23)
h = ASC(MID$(s$,21,1))*16777216 + ASC(MID$(s$,22,1))*65536 + ASC(MID$(s$,23,1))*256 + ASC(MID$(s$,24,1))

close #1
mode 1:cls

Edited 2025-07-20 19:24 by Martin H.
'no comment
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 07:46am 23 Jul 2025
Copy link to clipboard 
Print this post

Sorry Martin, I forgot to thank you for that last post. It IS very useful, I did incorporate it into the program and it works well. Yes, a GUI would be another very useful addition but the best I could probably come up with is a menu system to bump a threshold level up or down without having to edit the program each time.

Thanks again
Bill
Keep safe. Live long and prosper.
 
     Page 2 of 2    
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025