Page 3 of 3
Re: Photon improvement
Posted: Tue Sep 29, 2015 3:59 pm
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!

Re: Photon improvement
Posted: Wed Sep 30, 2015 10:59 am
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

Re: Photon improvement
Posted: Wed Sep 30, 2015 12:37 pm
by dilwyn
Message forwarded to Wolfgang.
Re: Photon improvement
Posted: Mon Oct 19, 2015 12:14 pm
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
Re: Photon improvement
Posted: Fri Oct 23, 2015 1:08 pm
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
GIF (incl. animated) being done, ZX screenshots and at least PNG also.
Re: Photon improvement
Posted: Sat Oct 24, 2015 12:28 pm
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

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
Re: Photon improvement
Posted: Wed Oct 28, 2015 2:47 pm
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.
Re: Photon improvement
Posted: Wed Oct 28, 2015 11:23 pm
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

Re: Photon improvement
Posted: Thu Oct 29, 2015 10:49 am
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
Re: Photon improvement
Posted: Mon Nov 02, 2015 9:46 pm
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