Main Menu

Shoutbox

Jackdaw

2025-09-26, 22:07:30
Well you learn something new every day. There is a fork of Blender 3D called Bforartists, that has a much better GUI than Blender's own. You'll find the link to it in the new github page in found in https://www.syntaxboom.com/forum/index.php?topic=25.0

Baggey

2025-09-24, 17:57:11
They'll be using Expanding foam to glue bricks together next  :-X

Dabzy

2025-09-24, 06:09:52
You can also get the expanding foam post fix, but, I wouldnt trust it really, especially where I live on the side of a valley and when the storms blow in the right direction, whistling down the valley, nowt is safe!

Baggey

2025-09-23, 08:53:01
That Postcrete stuff is amazing. I never know how much water to add. May be i should read the Instructions  ;D 

Dabzy

2025-09-22, 21:33:46
Cannot beat a breaky uppy mode, saves the hand cramps and chipped knuckles knocking ten bells out of a chod of conc with a hammer and chisel.

GfK

2025-09-22, 21:28:44
I have a massive JCB drill with a concrete breaky uppy mode which has got me out of jail free a couple of times replacing rotted fence posts that has been concreted in.

Amon

2025-09-22, 19:23:30
What about Roly?

Dabzy

2025-09-22, 19:22:35
Putting my 2 deckings in.... I've dug enough post holes to last me a life time... I feel sorry for the future poor sod who may want to shift'em... Like most things I do, I tend to go over the top, and as such, I've probably got shares in postcrete! :D

GfK

2025-09-22, 19:10:57
Round is a shape.

Baggey

2025-09-22, 19:04:49
Consult a qualified electrician for compliance with BS 7671 and local building Regs! Avoid areas where future digging is likely. ;)

Members
  • Total Members: 55
  • Latest: Amon
Stats
  • Total Posts: 1,608
  • Total Topics: 198
  • Online today: 4
  • Online ever: 54 (Sep 14, 2025, 08:48 AM)
Users Online
  • Users: 0
  • Guests: 5
  • Total: 5
Welcome to SyntaxBoom. Please login or sign up.

Recent

rgb color value to DATA letter value, DATA letter value to rgb color value

Started by RemiD, Jun 30, 2025, 11:12 AM

Previous topic - Next topic

RemiD

demonstrates how to read the colors of an image, and convert these rgb colors values to letters string values,
then output a txt file with these letters values organized in a way that it is formated for DATA (blitzbasic),
then read the letters string values stored in DATA, and convert each letter string value to a rgb color, and write these colors on a image.
;rgb color value to DATA letter value
;DATA letter value to rgb color value

Graphics( 640, 360, 32, 2 )

;create a image (or load a image)
Local in_image = CreateImage( 8, 4 )
SetBuffer( ImageBuffer( in_image ) )
Color( 250, 000, 000 ) : Plot( 0, 0 ) : Color( 250, 250, 250 ) : Plot( 1, 0 ) : Color( 250, 250, 250 ) : Plot( 2, 0 ) : Color( 001, 001, 001 ) : Plot( 3, 0 ) : Color( 001, 001, 001 ) : Plot( 4, 0 ) : Color( 250, 250, 250 ) : Plot( 5, 0 ) : Color( 250, 250, 250 ) : Plot( 6, 0 ) : Color( 250, 250, 000 ) : Plot( 7, 0 )
Color( 000, 250, 000 ) : Plot( 0, 1 ) : Color( 250, 250, 250 ) : Plot( 1, 1 ) : Color( 001, 001, 001 ) : Plot( 2, 1 ) : Color( 125, 125, 125 ) : Plot( 3, 1 ) : Color( 125, 125, 125 ) : Plot( 4, 1 ) : Color( 001, 001, 001 ) : Plot( 5, 1 ) : Color( 250, 250, 250 ) : Plot( 6, 1 ) : Color( 000, 250, 250 ) : Plot( 7, 1 )
Color( 000, 000, 250 ) : Plot( 0, 2 ) : Color( 250, 250, 250 ) : Plot( 1, 2 ) : Color( 001, 001, 001 ) : Plot( 2, 2 ) : Color( 125, 125, 125 ) : Plot( 3, 2 ) : Color( 125, 125, 125 ) : Plot( 4, 2 ) : Color( 001, 001, 001 ) : Plot( 5, 2 ) : Color( 250, 250, 250 ) : Plot( 6, 2 ) : Color( 250, 000, 250 ) : Plot( 7, 2 )
Color( 125, 125, 125 ) : Plot( 0, 3 ) : Color( 250, 250, 250 ) : Plot( 1, 3 ) : Color( 250, 250, 250 ) : Plot( 2, 3 ) : Color( 001, 001, 001 ) : Plot( 3, 3 ) : Color( 001, 001, 001 ) : Plot( 4, 3 ) : Color( 250, 250, 250 ) : Plot( 5, 3 ) : Color( 250, 250, 250 ) : Plot( 6, 3 ) : Color( 125, 125, 125 ) : Plot( 7, 3 )

;read the texels colors of the image and convert them to letters (each letter corresponding to a color) 
;write these letters in a txt file
;each line having the format to hold string values in DATA (for blitzbasic)
fileh% = WriteFile( "letters_DATA.txt" )
If( fileH <> 0 )
 SetBuffer( ImageBuffer( in_image ) )
 For gy% = 0 To 4-1 Step+1
  linestr$ = "DATA "
  For gx% = 0 To 8-1 Step+1
   GetColor( gx, gy ) : r% = ColorRed() : g% = ColorGreen() : b% = ColorBlue()
   If( r = 001 And g = 001 And b = 001 ) : letterstr$ = "A" ;black
   Else If( r = 250 And g = 250 And b = 250 ) : letterstr$ = "B" ;white
   Else If( r = 125 And g = 125 And b = 125 ) : letterstr$ = "C" ;grey    
   Else If( r = 250 And g = 000 And b = 000 ) : letterstr$ = "D" ;red
   Else If( r = 000 And g = 250 And b = 000 ) : letterstr$ = "E" ;green
   Else If( r = 000 And g = 000 And b = 250 ) : letterstr$ = "F" ;blue
   Else If( r = 250 And g = 250 And b = 000 ) : letterstr$ = "G" ;yellow
   Else If( r = 000 And g = 250 And b = 250 ) : letterstr$ = "H" ;cyan
   Else If( r = 250 And g = 000 And b = 250 ) : letterstr$ = "I" ;magenta
   EndIf
   linestr = LineStr+Chr$(34)+letterstr+Chr$(34)+", "
  Next
  DebugLog( linestr )
  WriteLine( fileH, linestr )
 Next
 CloseFile( fileh ) : fileh = 0
EndIf

;debug the in image
ScaleImage( in_image, 10, 10 )
SetBuffer( BackBuffer() )
ClsColor( 000, 000, 000 ) : Cls()
Color( 250, 250, 250 ) : Text( GraphicsWidth()/2-80/2, 0, "in_image" )
DrawImage( in_image, GraphicsWidth()/2-ImageWidth(in_image)/2, GraphicsHeight()/2-ImageHeight(in_image)/2 )
Flip()
WaitKey()

;array to hold the letters values read from DATA
Dim letter_str$( 8, 4 )

;get the letters values stored in letters_DATA and put them in the letter array
Restore letters_DATA 
For row% = 1 To 4 Step+1
 For col% = 1 To 8 Step+1
  Read letterstr$ 
  letter_str( col, row ) = letterstr
 Next
Next 

;create a image with texels colors depending on the letters values held in letters_DATA ( and in the letter array )
Local out_image = CreateImage( 8, 4 )
SetBuffer( ImageBuffer( out_image ) )
For gx% = 1 To 8 Step+1
 For gy% = 1 To 4 Step+1
  If( letter_str( gx, gy ) = "A" ) : Color( 001, 001, 001 ) : Plot( gx-1, gy-1 ) ;black
  Else If( letter_str( gx, gy ) = "B" ) : Color( 250, 250, 250 ) : Plot( gx-1, gy-1 ) ;white
  Else If( letter_str( gx, gy ) = "C" ) : Color( 125, 125, 125 ) : Plot( gx-1, gy-1 ) ;grey
  Else If( letter_str( gx, gy ) = "D" ) : Color( 250, 000, 000 ) : Plot( gx-1, gy-1 ) ;red
  Else If( letter_str( gx, gy ) = "E" ) : Color( 000, 250, 000 ) : Plot( gx-1, gy-1 ) ;green
  Else If( letter_str( gx, gy ) = "F" ) : Color( 000, 000, 250 ) : Plot( gx-1, gy-1 ) ;blue
  Else If( letter_str( gx, gy ) = "G" ) : Color( 250, 250, 000 ) : Plot( gx-1, gy-1 ) ;yellow
  Else If( letter_str( gx, gy ) = "H" ) : Color( 000, 250, 250 ) : Plot( gx-1, gy-1 ) ;cyan
  Else If( letter_str( gx, gy ) = "I" ) : Color( 250, 000, 250 ) : Plot( gx-1, gy-1 ) ;magenta
  EndIf
 Next
Next

;debug the out image
ScaleImage( out_image, 10, 10 )
SetBuffer( BackBuffer() )
ClsColor( 000, 000, 000 ) : Cls()
Color( 250, 250, 250 ) : Text( GraphicsWidth()/2-90/2, 0, "out_image" )
DrawImage( out_image, GraphicsWidth()/2-ImageWidth(out_image)/2, GraphicsHeight()/2-ImageHeight(out_image)/2 )
Flip()
WaitKey()

End()

;letters values stored in DATA
.letters_DATA 
Data "D", "B", "B", "A", "A", "B", "B", "G"
Data "E", "B", "A", "C", "C", "A", "B", "H"
Data "F", "B", "A", "C", "C", "A", "B", "I"
Data "C", "B", "B", "A", "A", "B", "B", "C"