VisualFBEditor - IDE for FreeBasic

User projects written in or related to FreeBASIC.
Post Reply
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: VisualFBEditor - IDE for FreeBasic

Post by UEZ »

Thank you very much for your quick support. :)
Xusinboy Bekchanov
Posts: 791
Joined: Jul 26, 2018 18:28

Re: VisualFBEditor - IDE for FreeBasic

Post by Xusinboy Bekchanov »

UEZ wrote: Mar 11, 2024 12:44 Thank you very much for your quick support. :)
You're welcome.
PeterHu
Posts: 159
Joined: Jul 24, 2022 4:57

Re: VisualFBEditor - IDE for FreeBasic

Post by PeterHu »

May I ask is there any barcode related component/example in mff or VisualFBEditor?
Xusinboy Bekchanov
Posts: 791
Joined: Jul 26, 2018 18:28

Re: VisualFBEditor - IDE for FreeBasic

Post by Xusinboy Bekchanov »

PeterHu wrote: Apr 24, 2024 4:57 May I ask is there any barcode related component/example in mff or VisualFBEditor?
Here is an example barcode:

Code: Select all

'#Region "Form"
	#if defined(__FB_MAIN__) AndAlso Not defined(__MAIN_FILE__)
		#define __MAIN_FILE__
		#ifdef __FB_WIN32__
			#cmdline "Form1.rc"
		#endif
		Const _MAIN_FILE_ = __FILE__
	#endif
	#include once "mff/Form.bi"
	
	Using My.Sys.Forms
	
	Type Form1Type Extends Form
		Declare Sub Form_Paint(ByRef Sender As Control, ByRef Canvas As My.Sys.Drawing.Canvas)
		Declare Constructor
		
	End Type
	
	Constructor Form1Type
		#if _MAIN_FILE_ = __FILE__
			With App
				.CurLanguagePath = ExePath & "/Languages/"
				.CurLanguage = .Language
			End With
		#endif
		' Form1
		With This
			.Name = "Form1"
			.Text = "Form1"
			.Designer = @This
			.OnPaint = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control, ByRef Canvas As My.Sys.Drawing.Canvas), @Form_Paint)
			.SetBounds 0, 0, 799, 599
		End With
	End Constructor
	
	Dim Shared Form1 As Form1Type
	
	#if _MAIN_FILE_ = __FILE__
		App.DarkMode = False
		Form1.MainForm = True
		Form1.Show
		App.Run
	#endif
'#End Region

Sub fb_barcode(ByRef Canvas As My.Sys.Drawing.Canvas, x_pos As Integer, y_pos As Integer, txt As String, img_h As Integer, col As ULong, mult As Integer)
	Dim As String char(0 To 44) = {" ","$","%","*","+","-",".","/", _
								   "0","1","2","3","4","5","6","7","8","9", _
								   "A","B","C","D","E","F","G","H","I","J","K","L","M", _
								   "N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_"}
	Dim As UByte bars_data(0 To 44, 0 To 15) = {{1,0,0,0,1,1,1,0,1,0,1,1,1,0,1,0}, _
												{1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0}, _
												{1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0}, _
												{1,0,0,0,1,0,1,1,1,0,1,1,1,0,1,0}, _
												{1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0}, _
												{1,0,0,0,1,0,1,0,1,1,1,0,1,1,1,0}, _
												{1,1,1,0,0,0,1,0,1,0,1,1,1,0,1,0}, _
												{1,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0}, _
												{1,0,1,0,0,0,1,1,1,0,1,1,1,0,1,0}, _
												{1,1,1,0,1,0,0,0,1,0,1,0,1,1,1,0}, _
												{1,0,1,1,1,0,0,0,1,0,1,0,1,1,1,0}, _
												{1,1,1,0,1,1,1,0,0,0,1,0,1,0,1,0}, _
												{1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,0}, _
												{1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0}, _
												{1,0,1,1,1,0,0,0,1,1,1,0,1,0,1,0}, _
												{1,0,1,0,0,0,1,0,1,1,1,0,1,1,1,0}, _
												{1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0}, _
												{1,0,1,1,1,0,0,0,1,0,1,1,1,0,1,0}, _
												{1,1,1,0,1,0,1,0,0,0,1,0,1,1,1,0}, _
												{1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0}, _
												{1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,0}, _
												{1,0,1,0,1,1,1,0,0,0,1,0,1,1,1,0}, _
												{1,1,1,0,1,0,1,1,1,0,0,0,1,0,1,0}, _
												{1,0,1,1,1,0,1,1,1,0,0,0,1,0,1,0}, _
												{1,0,1,0,1,0,0,0,1,1,1,0,1,1,1,0}, _
												{1,1,1,0,1,0,1,0,0,0,1,1,1,0,1,0}, _
												{1,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0}, _
												{1,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0}, _
												{1,1,1,0,1,0,1,0,1,0,0,0,1,1,1,0}, _
												{1,0,1,1,1,0,1,0,1,0,0,0,1,1,1,0}, _
												{1,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0}, _
												{1,0,1,0,1,1,1,0,1,0,0,0,1,1,1,0}, _
												{1,1,1,0,1,0,1,1,1,0,1,0,0,0,1,0}, _
												{1,0,1,1,1,0,1,1,1,0,1,0,0,0,1,0}, _
												{1,0,1,0,1,0,0,1,1,0,0,0,1,1,1,0}, _
												{1,1,1,0,1,0,1,0,1,1,1,0,0,0,1,0}, _
												{1,0,1,1,1,0,1,0,1,1,1,0,0,0,1,0}, _
												{1,0,1,0,1,1,1,0,1,1,1,0,0,0,1,0}, _
												{1,1,1,0,0,0,1,0,1,0,1,0,1,1,1,0}, _
												{1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,0}, _
												{1,1,1,0,0,0,1,1,1,0,1,0,1,0,1,0}, _
												{1,0,0,0,1,0,1,1,1,0,1,0,1,1,1,0}, _
												{1,1,1,0,0,0,1,0,1,1,1,0,1,0,1,0}, _
												{1,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0}, _
												{1,0,0,0,1,1,1,0,1,0,1,1,1,0,1,0}}
	Dim As Integer i, j, x, y, z, img_w = (16 * mult)
	Dim As String txt_str = "*" + UCase(txt) + "*"
	
	If mult < 1 Then
		mult = 1
	End If
	img_h *= mult
	
	For y = 1 To Len(txt_str)
		For x = 0 To 44
			If char(x) = Mid(txt_str, y, 1) Then
				If mult > 1 Then
					j = 0
					For z = 0 To 15
						If bars_data(x, z) = 1 Then
							For i = 1 To mult
								Canvas.Line x_pos + ((y - 1) * img_w) + (z + j), y_pos + 0, x_pos + ((y - 1) * img_w) + z + j, y_pos + img_h - 1, col
								j += 1
							Next i
							j -= 1
						Else
							j += (mult - 1)
						End If
					Next z
				Else
					For z = 0 To 15
						If bars_data(x, z) = 1 Then
							Canvas.Line x_pos + ((y - 1) * img_w) + (z + j), y_pos + 0, x_pos + ((y - 1) * img_w) + z + j, y_pos + img_h - 1, col
						End If
					Next z
				End If
			End If
		Next x
	Next y
End Sub

Private Sub Form1Type.Form_Paint(ByRef Sender As Control, ByRef Canvas As My.Sys.Drawing.Canvas)
	fb_barcode(Canvas, 10, 10, "freebasic", 34, BGR(0, 0, 0), 1)
	fb_barcode(Canvas, 10, 60, "freebasic", 34, BGR(0, 0, 0), 2)
	fb_barcode(Canvas, 10, 155, "freebasic", 34, BGR(0, 0, 0), 3)
	fb_barcode(Canvas, 10, 280, "freebasic", 34, BGR(0, 0, 0), 4)
End Sub
Avata
Posts: 105
Joined: Jan 17, 2021 7:27

Re: VisualFBEditor - IDE for FreeBasic

Post by Avata »

Here are the URLs of some commonly used barcode recognition libraries.

ZBar:https://github.com/mchehab/zbar

ZXing:https://github.com/zxing/zxing
Xusinboy Bekchanov
Posts: 791
Joined: Jul 26, 2018 18:28

Re: VisualFBEditor - IDE for FreeBasic

Post by Xusinboy Bekchanov »

This topic also has a barcode reader:
https://freebasic.net/forum/viewtopic.php?p=171446
PeterHu
Posts: 159
Joined: Jul 24, 2022 4:57

Re: VisualFBEditor - IDE for FreeBasic

Post by PeterHu »

Thank you both very much!
Post Reply