Photon improvement

Anything QL Software or Programming Related.
User avatar
Cristian
QL Wafer Drive
Posts: 1024
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Photon improvement

Post by Cristian »

Silvester wrote:But I have provided an option on next Photon where you can specify upto which frame you want to decode to. If you like, you can use it as a identity game 'can you recognise this image/person?'. With each subsequent call to photon you can add more detail
Great idea! :)


Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: Photon improvement

Post by Silvester »

OK, the last version was pretty poor. Here's a considerably faster version:

Code: Select all

100 ip$='win1_photo_jpg'
110 bgnd$='643B0F' : REMark hex RGB background colour for Sepia
120 :
130 CLS : PRINT 'Decoding :'!ip$; : op$=ip$(1 TO LEN(ip$)-3)
140 DELETE op$&'pic' : error%=FJPEG(ip$,op$&'pic',32)
150 IF error% THEN PRINT ' - '; : REPORT#1;error% : STOP
160 b$=CHR$((HEX(bgnd$(3 TO 4))&&$1C)*8||(HEX(bgnd$(5 TO 6))&&$F8)DIV 8)
170 b$=b$&CHR$(HEX(bgnd$(1 TO 2))&&$F8||HEX(bgnd$(3))DIV 2)
180 ip%=FOP_IN(op$&'pic') : WGET#ip%,f%,x%,y%,l%,m% : size=FLEN(#ip%)
190 yb%=SCR_YLIM-y% : yu%=yb%/2 : yl%=yb%-yu% : op%=FOP_OVER(op$&'bgi')
200 xb%=SCR_XLIM-x% : x%=x%*2 : DIM x$(x%) : PRINT\'PIC to BGIMAGE : '
210 IF xb%>0
220   t%=xb%/2 : l$=FILL$(b$,2*t%) : r$=FILL$(b$,2*(xb%-t%)) : xp%=x%
230 ELSE
240   l$='' : r$='' : xp%=2*SCR_XLIM
250 END IF
260 y$=FILL$(b$,SCR_XLIM*2) : IF yb%<0 THEN y%=SCR_YLIM
270 FOR n%=1 TO yu% : PRINT#op%;y$;
280 FOR n%=1 TO y%
290   PRINT#op%;l$; : BGET#ip%;x$(1 TO x%) : PRINT#op%;x$(1 TO xp%);
300   PRINT#op%;r$; : AT 1,17 : PRINT FPOS(#ip%);' / ';size;'  '
310 END FOR n%
320 FOR n%=1 TO yl% : PRINT#op%;y$;
330 size=FLEN(#op%) : CLOSE#ip%,#op% : DELETE op$&'pic'
340 IF size<>SCR_XLIM*SCR_YLIM*2 THEN PRINT 'Oops, error' : STOP
350 PRINT 'Done, load wallpaper? (Y/N)' : k$=INKEY$(-1)
360 IF k$=='y' THEN BGIMAGE op$&'bgi'
(edited: improved b$ derivation)

I don't have access to ql-users or Wolfgang's email to inform him of a bug found in SMSQmulator 3v22 filing, perhaps someone could pass it on:

You can rename a file to same name as existing - you then have two files with same name (or many more). You don't get an overwrite prompt. Occurs with QPAC2 Files 'Move' or basic RENAME command. Copying a file to same name as existing does get the overwrite prompt.

Edit: Bug now solved :)
Last edited by Silvester on Thu Oct 08, 2015 2:48 pm, edited 3 times in total.


David
User avatar
dilwyn
Mr QL
Posts: 3065
Joined: Wed Dec 01, 2010 10:39 pm

Re: Photon improvement

Post by dilwyn »

Message forwarded to Wolfgang.


User avatar
BSJR
Trump Card
Posts: 220
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: Photon improvement

Post by BSJR »

Hi Silvester,

Thanks for the FJPEG Function. I have added this to my SQRview program, that so far only did uncompressed images and sprites. It's working fine on my QPC but I would like to know more before finalizing an upgrade.
I adapted the example in the manual text to find the dimensions, needed to calculate the resulting PIC space in memory. To test for available memory I would like to know if the JPG is also loaded in memory before processing or is this done directly from the device?
That could make a big difference on Aurora or QXL.
Also Photon 0.13 recognizes an 8-bit JPG and produces a B&W image. The FJPEG routine produced a green image. I managed to fix this in my Basic, so not a big problem.

PNG, GIF next?
BSJR


Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: Photon improvement

Post by Silvester »

A rough estimate for max working memory used for average JPEG image X pixels wide converted to mode 32:

6*64*((X+15) DIV 16) + X*2*16 + 1940 + FLEN(\flp1_photo_jpg)

BTW, all memory is used from common heap and is handed back before returning (ie. no SB data space requirements).

The file is loaded (FS.LOAD) to avoid slaving overhead, but next version of Photon you can choose buffer size.

Attached correction for 8-bit only jpegs turning green :mrgreen:

GIF (incl. animated) being done, ZX screenshots and at least PNG also.
Attachments
fjpeg008.zip
(5.99 KiB) Downloaded 176 times


David
User avatar
BSJR
Trump Card
Posts: 220
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: Photon improvement

Post by BSJR »

Hi Silvester,
A rough estimate for max working memory used for average JPEG image X pixels wide converted to mode 32:

6*64*((X+15) DIV 16) + X*2*16 + 1940 + FLEN(\flp1_photo_jpg)

BTW, all memory is used from common heap and is handed back before returning (ie. no SB data space requirements).
The file is loaded (FS.LOAD) to avoid slaving overhead, but next version of Photon you can choose buffer size.
I suspect the *2 in +X*2*16 is for mode 32/33, could be 1 for mode 16 and 3 for mode 64.
I will correct my SBasic.
Attached correction for 8-bit only jpegs turning green :mrgreen:
Thanks for the fix.
GIF (incl. animated) being done, ZX screenshots and at least PNG also.
Great news. Will these also be available as Functions like FJPEG?

BSJR


Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: Photon improvement

Post by Silvester »

Yes, I will do simple functions to output raw data for other formats. It's a convenient test bed for finding problems. But the next version of Photon will do the same as the functions and a lot more.


David
User avatar
dilwyn
Mr QL
Posts: 3065
Joined: Wed Dec 01, 2010 10:39 pm

Re: Photon improvement

Post by dilwyn »

Silvester wrote:Yes, I will do simple functions to output raw data for other formats. It's a convenient test bed for finding problems. But the next version of Photon will do the same as the functions and a lot more.
I look forward to the next version of Photon, Silvester :ugeek:


User avatar
BSJR
Trump Card
Posts: 220
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: Photon improvement

Post by BSJR »

Silvester wrote:Yes, I will do simple functions to output raw data for other formats. It's a convenient test bed for finding problems. But the next version of Photon will do the same as the functions and a lot more.
Thanks. Eager to see what can be done with "a lot more".
In the mean time I will prepare my SQRview for the coming formats.

Bob


User avatar
QLvsJAGUAR
Gold Card
Posts: 485
Joined: Tue Feb 15, 2011 8:42 am
Location: Lucerne, Switzerland
Contact:

Re: Photon improvement

Post by QLvsJAGUAR »

Can't wait for an enhanced version of Photon. I had another look on the good old year 2000 version the other day. I’ve learned that Photon has a nice wallpaper option (\w). Gave it a go and re-implemented wallpaper in the BOOT program of QL. Used a nice picture of a crow which I’ve photographed last summer. This tinkering with Photon eventually resulted in a new release of QL/E (v3.11) and THE DISTRIBUTION (v3.03). Follow the link in the signature below. QL forever! Cheers, Urs


QL forever!
https://www.sinclairql.net/ - Go and get THE DISTRIBUTION & QL/E!
https://www.youtube.com/QLvsJAGUAR/community - Blog
https://www.youtube.com/QLvsJAGUAR - Dedicated QL videos
Sinclair, QL, ATARI, JAGUAR, NUON, APPLE, NeXT, MiST & much more...
Videos, pictures & information
Post Reply