Logicielsmoto.com

Nous sommes le 28 Mar 2024, 14:10

Heures au format UTC + 1 heure




Poster un nouveau sujet Répondre au sujet  [ 7 messages ] 
Auteur Message
 Sujet du message: Image conversion in BASIC code
MessagePosté: 10 Jan 2019, 22:51 
Hors ligne

Inscription: 24 Oct 2018, 21:54
Messages: 12
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/


Dernière édition par zef le 10 Jan 2019, 23:41, édité 1 fois.

Haut
 Profil  
Répondre en citant le message  
MessagePosté: 10 Jan 2019, 23:13 
Hors ligne

Inscription: 06 Avr 2010, 01:59
Messages: 478
Hi,
interesting tool, good :good:

_________________
Image


Haut
 Profil  
Répondre en citant le message  
MessagePosté: 11 Jan 2019, 11:59 
Hors ligne

Inscription: 21 Aoû 2006, 09:06
Messages: 1802
Localisation: Brest
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
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
shoud be coded as
Code:
23971 PSET (226,191),-1
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
for 320x200x16 color mode.

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.

_________________
Good morning, that's a nice Tnetennba


Haut
 Profil  
Répondre en citant le message  
MessagePosté: 11 Jan 2019, 14:17 
Hors ligne

Inscription: 21 Aoû 2006, 09:06
Messages: 1802
Localisation: Brest
(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

_________________
Good morning, that's a nice Tnetennba


Haut
 Profil  
Répondre en citant le message  
MessagePosté: 11 Jan 2019, 18:50 
Hors ligne

Inscription: 24 Oct 2018, 21:54
Messages: 12
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.


Haut
 Profil  
Répondre en citant le message  
MessagePosté: 11 Jan 2019, 20:11 
Hors ligne

Inscription: 24 Oct 2018, 21:54
Messages: 12
Ok, LEN is a BASIC function :)


Haut
 Profil  
Répondre en citant le message  
MessagePosté: 11 Jan 2019, 20:19 
Hors ligne

Inscription: 21 Aoû 2006, 09:06
Messages: 1802
Localisation: Brest
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).

_________________
Good morning, that's a nice Tnetennba


Haut
 Profil  
Répondre en citant le message  
Afficher les messages postés depuis:  Trier par  
Poster un nouveau sujet Répondre au sujet  [ 7 messages ] 

Heures au format UTC + 1 heure


Qui est en ligne

Utilisateurs parcourant ce forum: Google [Bot] et 37 invités


Vous ne pouvez pas poster de nouveaux sujets
Vous ne pouvez pas répondre aux sujets
Vous ne pouvez pas éditer vos messages
Vous ne pouvez pas supprimer vos messages
Vous ne pouvez pas joindre des fichiers

Rechercher:
Aller à:  
Développé par phpBB® Forum Software © phpBB Group
Traduction par phpBB-fr.com