Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:00 29 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 : Problem with JPG/BMP and Waveshare RP2040-LCD-1.28

     Page 1 of 2    
Author Message
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 07:38am 19 Apr 2023
Copy link to clipboard 
Print this post

Hi,

I have tried the demo from Peter ( https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=15427 ). Unfortunately, the background image is not included.

I have therefore experimented with my own images, unfortunately with only moderate success... Diese beiden Bilder zeigen mein Problem, hier die Originale:
DSC03042.zip

...and this is how the JPG looks like:


...and this is the BMP:


This is how it should look:



I have the current beta version - ? mm.ver says 5.07.07

What's going wrong here? I have tried other images, also with different image programs...

Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 07:51am 19 Apr 2023
Copy link to clipboard 
Print this post

Are you using the framebuffer or loading direct to the display? If the framebuffer then this is what you would expect as it is only RGB121
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2140
Posted: 08:24am 19 Apr 2023
Copy link to clipboard 
Print this post

This will test the number of colours that the display is capable of producing, though it does need MISO to be connected to SDO on the display.

 'Display Colour Counter - requires MISO connected to LCD_SDO
 dim a$(2)=(" Blues"," Greens"," Reds")
 dim integer b, c, n
 for b=0 to 2
  n=0
  for c=0 to 255
   pixel 99,99,c<<b*8
   if pixel(99,99)=c<<b*8 then
    inc n
   endif
  next
  Print n;a$(b)
 next

Edited 2023-04-19 18:25 by phil99
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 08:56am 19 Apr 2023
Copy link to clipboard 
Print this post

@Peter:

I tried LOAD IMAGE and LOAD JPG. Can you give me "face" from your demo???
How can I generate RGB121 pictures?

@Phil: With your program nothing happens at all on the display - the clock hands from the previous program are still shown...

At the first attempt (to save the previous program), XMODEM SEND gave the error NOT ENOUGH MEMORY!?
Only after an aborted XMODEM RECEIVE I could send my previous program successfully...

Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 10:36am 19 Apr 2023
Copy link to clipboard 
Print this post

You haven't answered the question. If you are loading an image to a framebuffer or moving it to a framebuffer it is compressed to RGB121 - the same colour set as the PicoMiteVGA. To create a RGB121 image to your specification you would need to tell your photo program what the VGA palette is and get it to just use those colours but you are still limited to just the 16.
If you are not using the framebuffer then there may be a bug but please just reset the Pico and then load your image from the command line - nothing else - is it OK then?
My image is not useful. It is a greyscale image that I have manipulated and just has the dial markings
Edited 2023-04-19 20:37 by matherp
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 11:52am 19 Apr 2023
Copy link to clipboard 
Print this post

Sorry Peter,

I did not understand your question.
Do you mean I should run LOAD JPG from Console?
If yes, then it behaves a bit strange:
> files
A:/
  <DIR>  .
  <DIR>  ..
00:00 01-01-2000          4  bootcount
00:02 01-01-2000      39808  DSC03042.jpg
2 directories, 2 files
> load jpg "DSC03042"
Error: Invalid address - resetting
PicoMite MMBasic Version 5.07.07RC4
Copyright 2011-2023 Geoff Graham
Copyright 2016-2023 Peter Mather

> load jpg "DSC03042"
>


After that the image looks better:



Is that what you need from me? ...if not, please tell me what to enter...

Frank

UPDATE: This behavior is reproducable! When I call LOAD JPG without FILES in front of it, nothing happens - no other image, just nothing at all!

But if I call FILES before, every time after LOAD JPG the "Invalid address" error comes. After the reset I can load the image correctly.

When I then start the program, it looks again like the pictures at the top.
Edited 2023-04-19 22:03 by Frank N. Furter
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2140
Posted: 12:42pm 19 Apr 2023
Copy link to clipboard 
Print this post

Peter fixed the memory issue with files some time ago. Try RC5 that seems ok.

The colour counter only uses a single pixel, so that is why you didn't see anything on the screen.
On the console you should see something like this:-

> RUN
 64 Blues
 64 Greens
 64 Reds
>

or this:-

> RUN
 32 Blues
 64 Greens
 32 Reds
>

Something is wrong if you get this:-

> RUN
 1 Blues
 2 Greens
 1 Reds
>

However you needn't bother as your last photo shows the display is working properly.
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1115
Posted: 12:58pm 19 Apr 2023
Copy link to clipboard 
Print this post

The Image has more Colors than the Pico can display

Here is an Online Ditherer, where you can save (copy and Past) a Custom Color Palette and it dithers in many different ways:
https://ditherit.com/


the Custom Palette for the Pico to past in looks like this:

[{"hex":"#000000"},
{"hex":"#FF0000"},
{"hex":"#0000FF"},
{"hex":"#FF00FF"},
{"hex":"#004000"},
{"hex":"#FF4000"},
{"hex":"#0040FF"},
{"hex":"#FF40FF"},
{"hex":"#008000"},
{"hex":"#FF8000"},
{"hex":"#0080FF"},
{"hex":"#FF80FF"},
{"hex":"#00FF00"},
{"hex":"#FFFF00"},
{"hex":"#00FFFF"},
{"hex":"#FFFFFF"}]


then it might look like this:


'no comment
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 01:22pm 19 Apr 2023
Copy link to clipboard 
Print this post

@Phil:
  Quote  Peter fixed the memory issue with files some time ago. Try RC5 that seems ok.

Where can I find RC5? I just downloaded RC4 yesterday as the latest beta version from Geoffs site...
  Quote  However you needn't bother as your last photo shows the display is working properly.

Yes, the display seems to be ok - so the picture would be fine.

@Martin:
  Quote  The Image has more Colors than the Pico can display

I don't think so - the image is displayed properly after the RESET.

Frank
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2140
Posted: 01:27pm 19 Apr 2023
Copy link to clipboard 
Print this post

RC5
https://www.thebackshed.com/forum/ViewTopic.php?TID=15793&P=4#202272
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 02:04pm 19 Apr 2023
Copy link to clipboard 
Print this post

Thanks for the link! Unfortunately RC5 behaves the same way!  

Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 02:19pm 19 Apr 2023
Copy link to clipboard 
Print this post

Please list options, delete anything in the library, specify exactly which version you are running and give me an exact sequence of commands that goes wrong following a H/W reset
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 06:51am 20 Apr 2023
Copy link to clipboard 
Print this post

Hi Peter,

I tried 5.07.07RC4 and the latest RC5 from yesterday - all the same!
These are all options:
> option list
PicoMite MMBasic Version 5.07.07RC5
OPTION SYSTEM SPI GP10,GP11,GP28
OPTION COLOURCODE ON
OPTION LCDPANEL GC9A01, LANDSCAPE,GP8,GP12,GP9,GP25
>

I have never used the library. I used your program with only marginal changes. Only BACKGROUND and LOAD JPG was added (LOAD IMAGE behaved the same with the corresponding BMP).
Option explicit
Option default none
'
Const Y_top = 0 'Y coordinate of top of the image file on the screen
Const X_left = 0 'X coordinate of left of the image file on the screen
Const s_Y_point = 172 'Y coordinate of the centre of the second hand relative to the image top
Const s_X_point = 119 'X coordinate of the centre of the second hand relative to the image left
Const h_Y_point = 119 'Y coordinate of the centre of the hour and minute hands relative to the image top
Const h_X_point = 120 'X coordinate of the centre of the hour and minute hands relative to the image top
Const sl=-30
Const ml=-100
Const hl=-75

Backlight 100

'
'
'
' Now we define the pointers as the X,Y coordinates of a number of triangles with the rotation point at 0,0
' It is simplest to define this in the 12-oclock position which means the Y-coordinates at the top of the pointer will be negative
' The order of data elements in the array is:
' t1x1,t1y1,t1x2,t1y2,t1x3,t1y3, t2x1,t2y1,t2x2,t2y2,t2x3,t2y3,...tntx1,tnty1,tntx2,tnty2,tntx3,tnty3
'
Dim integer nt=6 'Number of triangles used to define the pointer
Dim integer x1(nt-1)=(-1,-1,-2,-2,-3,-3)
Dim integer y1(nt-1)=(0,0,0,0,0,0)
Dim integer x2(nt-1)=(-1,1,-2,2,-3,3)
Dim integer y2(nt-1)=(sl,sl,ml,ml,hl,hl)
Dim integer x3(nt-1)=(1,1,2,2,3,3)
Dim integer y3(nt-1)=(sl,0,ml,0,hl,0)
Dim INTEGER pcolour=RGB(Green) 'define the colour of the pointer
Const s_pivot=3, m_pivot=5, h_pivot=3 'diameter in pixels of the fulcrum of the pointer
'
Dim integer xx0(nt-1),yy0(nt-1),xx1(nt-1),yy1(nt-1),xx2(nt-1),yy2(nt-1),tcol(nt-1)
Dim integer first=1 'marker to control alternate processing on first time through the loop

'
FRAMEBUFFER create
FRAMEBUFFER layer
FRAMEBUFFER write l
CLS
Load JPG "DSC03042"
'Load Image "DSC03042"
'
' demo code moving the pointer
Dim float secondangle=0, minuteangle=0, hourangle=0
Do
FRAMEBUFFER copy l,f
If secondangle Mod 60=0 Then Inc minuteangle,1
If (minuteangle Mod 72=0) And (secondangle Mod 60=0) Then Inc hourangle,6
drawpointer
FRAMEBUFFER copy f,n
Inc secondangle,6

Loop
'
Sub drawpointer
Local integer i,x,y
Local float angle
For i=0 To nt-1
  If i<2 Then
    x=s_X_point
    y=s_Y_point
    pcolour=RGB(red)
    angle=secondangle
  Else
    x=h_X_point
    y=h_Y_point
    pcolour=RGB(white)
    If i<4 Then
      angle=minuteangle
    Else
      angle=hourangle
    EndIf
  EndIf
  rotatetriangle(i,pcolour,angle,x+X_left,y+Y_top,x1(i),y1(i),x2(i),y2(i),x3(i),y3(i)) 'rotate the pointer into the drawing array
Next i
FRAMEBUFFER write f
Triangle xx0(), yy0(), xx1(), yy1(), xx2(), yy2(),tcol(),tcol()
drawpivot
End Sub

Sub rotatetriangle(n As integer, col As integer, angle As float, x As integer,y As integer, x0 As integer, y0 As integer, x1 As integer, y1 As integer, x2 As integer, y2 As integer)
Local float sine=Sin(Rad(angle)),cosine=Cos(Rad(angle))
Local integer x0a,y0a,x1a,y1a,x2a,y2a
x0a= x0*cosine - y0 * sine + x
y0a= y0*cosine + x0 * sine + y
x1a= x1*cosine - y1 * sine + x
y1a= y1*cosine + x1 * sine + y
x2a= x2*cosine - y2 * sine + x
y2a= y2*cosine + x2 * sine + y
xx0(n)=x0a
yy0(n)=y0a
xx1(n)=x1a
yy1(n)=y1a
xx2(n)=x2a
yy2(n)=y2a
tcol(n)=pcolour
End Sub
'
Sub drawpivot() 'put anything you like here to draw the fulcrum as you wish
Circle s_X_point+X_left,s_Y_point+Y_top,s_pivot,0,,,RGB(green)
Circle h_X_point+X_left,h_Y_point+Y_top,m_pivot,0,,,RGB(white)
Circle h_X_point+X_left,h_Y_point+Y_top,h_pivot,0,,,RGB(black)

End Sub      

If I start your program, quit (CTRL-C) and call LOAD JPG "DSC03042", nothing happens. But if I type FILES before that and then LOAD JPG "DSC03042", the system crashes and reboots. If I then enter LOAD JPG "DSC03042", the image is displayed correctly.
When I start the program again, the image is displayed incorrectly again. During this procedure, the OPTION AUTOSTART ON function was apparently also lost...
This is reproducible with RC4 and RC5 for me.
Before I used RC5, I first flashed "Clear_flash.uf2".

Here you can see what I just entered:
> option list
PicoMite MMBasic Version 5.07.07RC5
OPTION SYSTEM SPI GP10,GP11,GP28
OPTION COLOURCODE ON
OPTION LCDPANEL GC9A01, LANDSCAPE,GP8,GP12,GP9,GP25
> LIBRARY DELETE
> run
> Load JPG "DSC03042"
> run
> Load JPG "DSC03042"
> files
A:/
  <DIR>  .
  <DIR>  ..
00:00 01-01-2000          4  bootcount
00:01 01-01-2000      39808  DSC03042.jpg
2 directories, 2 files
> Load JPG "DSC03042"
Error: Invalid address - resetting
PicoMite MMBasic Version 5.07.07RC5
Copyright 2011-2023 Geoff Graham
Copyright 2016-2023 Peter Mather

> Load JPG "DSC03042"
> run

LIBRARY DELETE has no influence. At the lowest LOAD JPG call the image is displayed correctly, at the following RUN the image is wrong again.

Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 08:03am 20 Apr 2023
Copy link to clipboard 
Print this post

OK Let's go through this bit by bit

  Quote  If I start your program, quit (CTRL-C) and call LOAD JPG "DSC03042", nothing happens.


This is because the image is being written to a framebuffer and not the screen after you ctrl-C out of the program. Framebuffers need to be understood and treated with caution.

  Quote  But if I type FILES before that and then LOAD JPG "DSC03042", the system crashes and reboots.

This is a bug that I think I have found and fixed in RC6. Please let me know once posted

  Quote  When I start the program again, the image is displayed incorrectly again.

This is correct. The image is being compressed to RGB121 when copied into the framebuffer. The image will only ever show properly if loaded direct into the display itself.

  Quote  If I then enter LOAD JPG "DSC03042", the image is displayed correctly.

This is because after a reset the image is sent directly to the screen
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 11:31am 20 Apr 2023
Copy link to clipboard 
Print this post

...exact same behavior with RC6:
> load jpg  "DSC03042"
> files
A:/
  <DIR>  .
  <DIR>  ..
00:00 01-01-2000          4  bootcount
00:01 01-01-2000      39808  DSC03042.jpg
2 directories, 2 files
> load jpg  "DSC03042"
Error: Invalid address - resetting
PicoMite MMBasic Version 5.07.07RC6
Copyright 2011-2023 Geoff Graham
Copyright 2016-2023 Peter Mather

>


Frank
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4253
Posted: 12:19pm 20 Apr 2023
Copy link to clipboard 
Print this post

Hi Martin,

I would use THIS as a pallette for "dither_it".
Green can be 0, 1/3, 2/3 or 1 (not 0, 1/4, 1/2, 1 as suggested above).

[{"hex":"#000000"},
{"hex":"#FF0000"},
{"hex":"#0000FF"},
{"hex":"#FF00FF"},
{"hex":"#005500"},
{"hex":"#FF5500"},
{"hex":"#0055FF"},
{"hex":"#FF55FF"},
{"hex":"#00AA00"},
{"hex":"#FFAA00"},
{"hex":"#00AAFF"},
{"hex":"#FFAAFF"},
{"hex":"#00FF00"},
{"hex":"#FFFF00"},
{"hex":"#00FFFF"},
{"hex":"#FFFFFF"}]


Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 12:41pm 20 Apr 2023
Copy link to clipboard 
Print this post

  Quote  ..exact same behavior with RC6:


Please post the jpg. I can't replicate with my normal "tiger" test jpg
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 01:10pm 20 Apr 2023
Copy link to clipboard 
Print this post

DSC03042.zip
Can you send me your tiger? It happens here with all JPG's that I try...

Frank
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2140
Posted: 01:41pm 20 Apr 2023
Copy link to clipboard 
Print this post

There is something not quit right with the JPG compression of that image.

First time I loaded it no problem but after files:-
.
.
.
01:45 01-01-2000     230454  VGAPico_Test.bmp
11:55 20-04-2023       5812  VU Meter.bas
11:20 20-04-2023     460854  VUmeter.bmp
3 directories, 124 files
> load jpg "DSC03042a.jpg"
Error : pjpeg_decode_init() failed with status 19
>

Made a new JPG from the original BMP using Irfanview and it loads without problems after files.
Also tried another JPG much bigger than the screen, still no problem.

Try this.

Right click on the image an choose "save image as".
Edited 2023-04-20 23:43 by phil99
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 831
Posted: 02:01pm 20 Apr 2023
Copy link to clipboard 
Print this post

I renamed it to "A.jpg" - same behavior:
> load jpg "A"
> files
A:/
  <DIR>  .
  <DIR>  ..
00:01 01-01-2000       9472  A.jpg
00:00 01-01-2000          4  bootcount
00:18 01-01-2000      14592  DSC03042.jpg
2 directories, 3 files
> load jpg "A"
Error: Invalid address - resetting
PicoMite MMBasic Version 5.07.07RC6
Copyright 2011-2023 Geoff Graham
Copyright 2016-2023 Peter Mather

>


Frank
 
     Page 1 of 2    
Print this page
© JAQ Software 2024