Logicielsmoto.com http://www.logicielsmoto.com/phpBB/ |
|
Image conversion in BASIC code http://www.logicielsmoto.com/phpBB/viewtopic.php?f=3&t=583 |
Page 1 sur 1 |
Auteur: | zef [ 10 Jan 2019, 22:51 ] |
Sujet du message: | Image conversion in BASIC code |
Hello everyone, I have created an online tool for image conversion to the basic code 128/512, this is the link:: http://retrohead.appodesign.com/ |
Auteur: | adnz [ 10 Jan 2019, 23:13 ] |
Sujet du message: | Re: Iimage conversion in BASIC code |
Hi, interesting tool, good |
Auteur: | Samuel Devulder [ 11 Jan 2019, 11:59 ] |
Sujet du message: | Re: Image conversion in BASIC code |
If you wish, you could use the conversion algorithms that I designed for GrafX2 and which are available in the Zip file of >>this message<<. From what I can see, this tool generates a list of basic instruction to draw the picture via PSET and LINE instructions. Is it fast to display ? I think that there might be a bug in the produced BASIC code for pictures in 320x200 16colors. Adjacent pixels of consecutive colors should alternate positive and negative values to switch between background and foreground colors, otherwise you'd get color clashes (the last plot color will bleed onto the previous ones.) Eg I mean things like: Code: 23971 PSET (226,191),0 shoud be coded as 23972 PSET (227,191),3 23973 PSET (228,191),0 23974 LINE (229,191)-(231,191),3 23975 PSET (232,191),9 23976 PSET (233,191),6 23977 PSET (234,191),9 23978 PSET (235,191),6 Code: 23971 PSET (226,191),-1 for 320x200x16 color mode.23972 PSET (227,191),3 23973 PSET (228,191),-1 23974 LINE (229,191)-(231,191),3 23975 PSET (232,191),-10 23976 PSET (233,191),6 23977 PSET (234,191),-10 23978 PSET (235,191),6 I also noticed an issue with the SAVEP line: Code: 24659 DIM IM%(3000): SAVEP"www",IM%(3000) It misses a GET(0,0)-(40,25),IM%(3000) instruction before the SAVEP instruction otherwise the saved file will not contain the picture. |
Auteur: | Samuel Devulder [ 11 Jan 2019, 14:17 ] |
Sujet du message: | Re: Image conversion in BASIC code |
(a bit of improvement) With all these PSET/LINE instructions, the resulting basic file is quite huge on the boat picture of the link above. I think that packing the data in a series of <length>,<color> DATA would reduce the size a lot. Eg: Code: 1000 X=0: Y=0: REM start of display 1010 READ LEN,COL 1020 IF LEN=1 THEN PSET(X,Y),COL ELSE LINE(X,Y)-(X+LEN-1),COL: REM it is possible to only use LINE if one wishes 1030 X=X+LEN 1040 IF X>=320 THEN X=0:Y=Y+1 1050 IF Y<200 THEN 1010 1060 GOTO 1060: REM end of display 2000 DATA ...: REM lots of data describing the image 2010 DATA 1,-1,1,3,1,-1,3,3,1,-10,1,6,1-10,1,6 2020 DATA ...: REM etc... One can even imagine an even smaller encoding. Let N be a number. It can be split into C and L such that N=C+L*16. Using that we can encode both the length and the color into a single number. Notice that the color sign isn't alternating this time, but this can be retrieved easily with the "XOR" trick below Code: 1000 X=0: Y=0: C=0
1010 READ N 1020 L = N@16: REM extract length 1030 C = (N AND 15) XOR (C>=0): REM extract (alternating sign) color 1040 LINE(X,Y)-(X+L,Y),C 1050 X=X+1+L: IF X>=320 THEN X=0:Y=Y+1 1060 IF Y<200 THEN 1010 1070 GOTO 1070 2000 DATA ... 2010 DATA 0,3,0: REM draw consecutive pixels of color -1,3,-1 2020 DATA 35: REM 35 = 2*16 + 3 meaning then draw a line of 2+1=3 pixels wide with color 3 2030 DATA 9,6,9,6: REM continue with consecutive pixels of color -10,6,-10,6 |
Auteur: | zef [ 11 Jan 2019, 18:50 ] |
Sujet du message: | Re: Image conversion in BASIC code |
Hello Samuel, thanks for your directions, I had in anticipation of solving the problem of color / background in mode 0. I was trying your code, but I get a Syntax error in the line 1010 READ LEN, COL. |
Auteur: | zef [ 11 Jan 2019, 20:11 ] |
Sujet du message: | Re: Image conversion in BASIC code |
Ok, LEN is a BASIC function |
Auteur: | Samuel Devulder [ 11 Jan 2019, 20:19 ] |
Sujet du message: | Re: Image conversion in BASIC code |
yeah, I wrote the basic code directly on the page without checking the syntax. But the basis of the decoding algorithm is okay. BTW: better try the 2nd version with the L,C variable (and the @16 operation which is an integer division by 16): it'll be 50% more compact than the version with COLOR,LEN pair. Notice: if you do Code: DEFINT A-Z in the beginning of the code, all variables will be of type "integer" and operations will execute faster than with default variable type (32bits floats in the case of Thomson basic).
|
Page 1 sur 1 | Heures au format UTC + 1 heure |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |