توسيط سطر معين - محمود صالح - 04-01-18
سلام عليكم
الاكواد لملصق الباركود كله شغال تمام بس انا اريد توسيط رسم السطور التالية
كود :
GraphZ.DrawString(TheText, New Font("Arial", 8, FontStyle.Regular), New SolidBrush(Color.Black), 0, 40)
GraphZ.DrawString(STR, New Font("Arial", 8, FontStyle.Bold), New SolidBrush(Color.Black), 0, 0)
GraphZ.DrawString(STR1, New Font("Arial", 8, FontStyle.Bold), New SolidBrush(Color.Black), 0, 51)
كما هو معروف في اخر الكود بيطلب محور (س \ ص) مكان السطر يعني
انا عاوز اخليه في المنتصف الملصق
وده الكلاس كامل
كود :
Public Class barcode
'دوال رسم الباركود
Function Code128(ByVal TheText As String, ByVal CodeLetter As String, Optional STR As String = "", Optional STR1 As String = "") As Image
' TheText متغير خاص بالنص المراد تشفيره
' CodeLetter متغير خاص بالفئة المراد استخدامها
Dim Binaryz As String = "" 'متغير سيحمل النص بعد تحويله إلى باينرى
Dim I As Integer
Dim NumCode As Integer 'متغير سيحمل قيمة حساب النص التكميلى
If CodeLetter = "A" Or CodeLetter = "a" Then
NumCode = 103
Binaryz = "00101111011"
End If
If CodeLetter = "B" Or CodeLetter = "b" Then
NumCode = 104
Binaryz = "00101101111"
End If
If CodeLetter = "C" Or CodeLetter = "c" Then
NumCode = 105
Binaryz = "00101100011"
End If
' الكود التالى سيقوم باسناد قيمة الحرف بالباينرى حسب الجدول الخاص بالكود 128
For I = 1 To Len(TheText)
NumCode = NumCode + ((Asc(Mid(TheText, I, 1)) - 32) * I)
Select Case Asc(Mid(TheText, I, 1))
Case 32
Binaryz = Binaryz & "00100110011"
Case 33
Binaryz = Binaryz & "00110010011"
Case 34
Binaryz = Binaryz & "00110011001"
Case 35
Binaryz = Binaryz & "01101100111"
Case 36
Binaryz = Binaryz & "01101110011"
Case 37
Binaryz = Binaryz & "01110110011"
Case 38
Binaryz = Binaryz & "01100110111"
Case 39
Binaryz = Binaryz & "01100111011"
Case 40
Binaryz = Binaryz & "01110011011"
Case 41
Binaryz = Binaryz & "00110110111"
Case 42
Binaryz = Binaryz & "00110111011"
Case 43
Binaryz = Binaryz & "00111011011"
Case 44
Binaryz = Binaryz & "01001100011"
Case 45
Binaryz = Binaryz & "01100100011"
Case 46
Binaryz = Binaryz & "01100110001"
Case 47
Binaryz = Binaryz & "01000110011"
Case 48
Binaryz = Binaryz & "01100010011"
Case 49
Binaryz = Binaryz & "01100011001"
Case 50
Binaryz = Binaryz & "00110001101"
Case 51
Binaryz = Binaryz & "00110100011"
Case 52
Binaryz = Binaryz & "00110110001"
Case 53
Binaryz = Binaryz & "00100011011"
Case 54
Binaryz = Binaryz & "00110001011"
Case 55
Binaryz = Binaryz & "00010010001"
Case 56
Binaryz = Binaryz & "00010110011"
Case 57
Binaryz = Binaryz & "00011010011"
Case 58
Binaryz = Binaryz & "00011011001"
Case 59
Binaryz = Binaryz & "00010011011"
Case 60
Binaryz = Binaryz & "00011001011"
Case 61
Binaryz = Binaryz & "00011001101"
Case 62
Binaryz = Binaryz & "00100100111"
Case 63
Binaryz = Binaryz & "00100111001"
Case 64
Binaryz = Binaryz & "00111001001"
Case 65
Binaryz = Binaryz & "01011100111"
Case 66
Binaryz = Binaryz & "01110100111"
Case 67
Binaryz = Binaryz & "01110111001"
Case 68
Binaryz = Binaryz & "01001110111"
Case 69
Binaryz = Binaryz & "01110010111"
Case 70
Binaryz = Binaryz & "01110011101"
Case 71
Binaryz = Binaryz & "00101110111"
Case 72
Binaryz = Binaryz & "00111010111"
Case 73
Binaryz = Binaryz & "00111011101"
Case 74
Binaryz = Binaryz & "01001000111"
Case 75
Binaryz = Binaryz & "01001110001"
Case 76
Binaryz = Binaryz & "01110010001"
Case 77
Binaryz = Binaryz & "01000100111"
Case 78
Binaryz = Binaryz & "01000111001"
Case 79
Binaryz = Binaryz & "01110001001"
Case 80
Binaryz = Binaryz & "00010001001"
Case 81
Binaryz = Binaryz & "00101110001"
Case 82
Binaryz = Binaryz & "00111010001"
Case 83
Binaryz = Binaryz & "00100010111"
Case 84
Binaryz = Binaryz & "00100011101"
Case 85
Binaryz = Binaryz & "00100010001"
Case 86
Binaryz = Binaryz & "00010100111"
Case 87
Binaryz = Binaryz & "00010111001"
Case 88
Binaryz = Binaryz & "00011101001"
Case 89
Binaryz = Binaryz & "00010010111"
Case 90
Binaryz = Binaryz & "00010011101"
Case 91
Binaryz = Binaryz & "00011100101"
Case 92
Binaryz = Binaryz & "00010000101"
Case 93
Binaryz = Binaryz & "00110111101"
Case 94
Binaryz = Binaryz & "00001110101"
Case 95
Binaryz = Binaryz & "01011001111"
Case 96
Binaryz = Binaryz & "01011110011"
Case 97
Binaryz = Binaryz & "01101001111"
Case 98
Binaryz = Binaryz & "01101111001"
Case 99
Binaryz = Binaryz & "01111010011"
Case 100
Binaryz = Binaryz & "01111011001"
Case 101
Binaryz = Binaryz & "01001101111"
Case 102
Binaryz = Binaryz & "01001111011"
Case 103
Binaryz = Binaryz & "01100101111"
Case 104
Binaryz = Binaryz & "01100111101"
Case 105
Binaryz = Binaryz & "01111001011"
Case 106
Binaryz = Binaryz & "01111001101"
Case 107
Binaryz = Binaryz & "00111101101"
Case 108
Binaryz = Binaryz & "00110101111"
Case 109
Binaryz = Binaryz & "00001000101"
Case 110
Binaryz = Binaryz & "00111101011"
Case 111
Binaryz = Binaryz & "01110000101"
Case 112
Binaryz = Binaryz & "01011000011"
Case 113
Binaryz = Binaryz & "01101000011"
Case 114
Binaryz = Binaryz & "01101100001"
Case 115
Binaryz = Binaryz & "01000011011"
Case 116
Binaryz = Binaryz & "01100001011"
Case 117
Binaryz = Binaryz & "01100001101"
Case 118
Binaryz = Binaryz & "00001011011"
Case 119
Binaryz = Binaryz & "00001101011"
Case 120
Binaryz = Binaryz & "00001101101"
Case 121
Binaryz = Binaryz & "00100100001"
Case 122
Binaryz = Binaryz & "00100001001"
Case 123
Binaryz = Binaryz & "00001001001"
Case 124
Binaryz = Binaryz & "01010000111"
Case 125
Binaryz = Binaryz & "01011100001"
Case 126
Binaryz = Binaryz & "01110100001"
Case 127
Binaryz = Binaryz & "01000010111"
Case 128
Binaryz = Binaryz & "01000011101"
Case 129
Binaryz = Binaryz & "00001010111"
Case 130
Binaryz = Binaryz & "00001011101"
Case 131
Binaryz = Binaryz & "01000100001"
Case 132
Binaryz = Binaryz & "01000010001"
Case 133
Binaryz = Binaryz & "00010100001"
Case 134
Binaryz = Binaryz & "00001010001"
Case 135
Binaryz = Binaryz & "00101111011"
Case 136
Binaryz = Binaryz & "00101101111"
Case 137
Binaryz = Binaryz & "00101100011"
Case 138
Binaryz = Binaryz & "0011100010100"
End Select
Next
NumCode = NumCode Mod 103
' الكود التالى لمعرفة الحرف المراد اضافتة لاستكمال النص
Select Case NumCode
Case 0
Binaryz = Binaryz & "00100110011"
Case 1
Binaryz = Binaryz & "00110010011"
Case 2
Binaryz = Binaryz & "00110011001"
Case 3
Binaryz = Binaryz & "01101100111"
Case 4
Binaryz = Binaryz & "01101110011"
Case 5
Binaryz = Binaryz & "01110110011"
Case 6
Binaryz = Binaryz & "01100110111"
Case 7
Binaryz = Binaryz & "01100111011"
Case 8
Binaryz = Binaryz & "01110011011"
Case 9
Binaryz = Binaryz & "00110110111"
Case 10
Binaryz = Binaryz & "00110111011"
Case 11
Binaryz = Binaryz & "00111011011"
Case 12
Binaryz = Binaryz & "01001100011"
Case 13
Binaryz = Binaryz & "01100100011"
Case 14
Binaryz = Binaryz & "01100110001"
Case 15
Binaryz = Binaryz & "01000110011"
Case 16
Binaryz = Binaryz & "01100010011"
Case 17
Binaryz = Binaryz & "01100011001"
Case 18
Binaryz = Binaryz & "00110001101"
Case 19
Binaryz = Binaryz & "00110100011"
Case 20
Binaryz = Binaryz & "00110110001"
Case 21
Binaryz = Binaryz & "00100011011"
Case 22
Binaryz = Binaryz & "00110001011"
Case 23
Binaryz = Binaryz & "00010010001"
Case 24
Binaryz = Binaryz & "00010110011"
Case 25
Binaryz = Binaryz & "00011010011"
Case 26
Binaryz = Binaryz & "00011011001"
Case 27
Binaryz = Binaryz & "00010011011"
Case 28
Binaryz = Binaryz & "00011001011"
Case 29
Binaryz = Binaryz & "00011001101"
Case 30
Binaryz = Binaryz & "00100100111"
Case 31
Binaryz = Binaryz & "00100111001"
Case 32
Binaryz = Binaryz & "00111001001"
Case 33
Binaryz = Binaryz & "01011100111"
Case 34
Binaryz = Binaryz & "01110100111"
Case 35
Binaryz = Binaryz & "01110111001"
Case 36
Binaryz = Binaryz & "01001110111"
Case 37
Binaryz = Binaryz & "01110010111"
Case 38
Binaryz = Binaryz & "01110011101"
Case 39
Binaryz = Binaryz & "00101110111"
Case 40
Binaryz = Binaryz & "00111010111"
Case 41
Binaryz = Binaryz & "00111011101"
Case 42
Binaryz = Binaryz & "01001000111"
Case 43
Binaryz = Binaryz & "01001110001"
Case 44
Binaryz = Binaryz & "01110010001"
Case 45
Binaryz = Binaryz & "01000100111"
Case 46
Binaryz = Binaryz & "01000111001"
Case 47
Binaryz = Binaryz & "01110001001"
Case 48
Binaryz = Binaryz & "00010001001"
Case 49
Binaryz = Binaryz & "00101110001"
Case 50
Binaryz = Binaryz & "00111010001"
Case 51
Binaryz = Binaryz & "00100010111"
Case 52
Binaryz = Binaryz & "00100011101"
Case 53
Binaryz = Binaryz & "00100010001"
Case 54
Binaryz = Binaryz & "00010100111"
Case 55
Binaryz = Binaryz & "00010111001"
Case 56
Binaryz = Binaryz & "00011101001"
Case 57
Binaryz = Binaryz & "00010010111"
Case 58
Binaryz = Binaryz & "00010011101"
Case 59
Binaryz = Binaryz & "00011100101"
Case 60
Binaryz = Binaryz & "00010000101"
Case 61
Binaryz = Binaryz & "00110111101"
Case 62
Binaryz = Binaryz & "00001110101"
Case 63
Binaryz = Binaryz & "01011001111"
Case 64
Binaryz = Binaryz & "01011110011"
Case 65
Binaryz = Binaryz & "01101001111"
Case 66
Binaryz = Binaryz & "01101111001"
Case 67
Binaryz = Binaryz & "01111010011"
Case 68
Binaryz = Binaryz & "01111011001"
Case 69
Binaryz = Binaryz & "01001101111"
Case 70
Binaryz = Binaryz & "01001111011"
Case 71
Binaryz = Binaryz & "01100101111"
Case 72
Binaryz = Binaryz & "01100111101"
Case 73
Binaryz = Binaryz & "01111001011"
Case 74
Binaryz = Binaryz & "01111001101"
Case 75
Binaryz = Binaryz & "00111101101"
Case 76
Binaryz = Binaryz & "00110101111"
Case 77
Binaryz = Binaryz & "00001000101"
Case 78
Binaryz = Binaryz & "00111101011"
Case 79
Binaryz = Binaryz & "01110000101"
Case 80
Binaryz = Binaryz & "01011000011"
Case 81
Binaryz = Binaryz & "01101000011"
Case 82
Binaryz = Binaryz & "01101100001"
Case 83
Binaryz = Binaryz & "01000011011"
Case 84
Binaryz = Binaryz & "01100001011"
Case 85
Binaryz = Binaryz & "01100001101"
Case 86
Binaryz = Binaryz & "00001011011"
Case 87
Binaryz = Binaryz & "00001101011"
Case 88
Binaryz = Binaryz & "00001101101"
Case 89
Binaryz = Binaryz & "00100100001"
Case 90
Binaryz = Binaryz & "00100001001"
Case 91
Binaryz = Binaryz & "00001001001"
Case 92
Binaryz = Binaryz & "01010000111"
Case 93
Binaryz = Binaryz & "01011100001"
Case 94
Binaryz = Binaryz & "01110100001"
Case 95
Binaryz = Binaryz & "01000010111"
Case 96
Binaryz = Binaryz & "01000011101"
Case 97
Binaryz = Binaryz & "00001010111"
Case 98
Binaryz = Binaryz & "00001011101"
Case 99
Binaryz = Binaryz & "01000100001"
Case 100
Binaryz = Binaryz & "01000010001"
Case 101
Binaryz = Binaryz & "00010100001"
Case 102
Binaryz = Binaryz & "00001010001"
End Select
Binaryz = Binaryz & "0011100010100" ' انهاء الكود باضافة الباينرى الخاص بايقاف جميع الاكواد
' انشاء صورة عرضها عدد حروف الباينرى المستخدم
Dim bmp As Bitmap = New Bitmap(Len(Binaryz), 70, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim z As String ' متغير لمعرفة لون الخط
Dim GraphZ As Graphics = Graphics.FromImage(bmp)
Dim RectZ As Rectangle = New Rectangle(0, 0, bmp.Width, bmp.Height) ' مستطيل بحجم الصورة لاعطاء الخلفية باللون الابيض
' فرشاه لدهان المستطيل السابق باللون الابيض
Dim myBrush As Brush = New Drawing.Drawing2D.LinearGradientBrush(RectZ, Color.White, Color.White, Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal)
' دهان المستطيل السابق باللون الابيض
GraphZ.FillRectangle(myBrush, RectZ)
' رسم خطوط الباركود
Dim PenZ As Pen
Dim point1 As Point ' نقطة بداية الخط
Dim point2 As Point ' نقطة نهاية الخط
For I = 1 To Len(Binaryz)
z = Mid(Binaryz, I, 1)
If z = "0" Then
PenZ = New Pen(Color.Black, 1)
point1 = New Point(I, 15)
point2 = New Point(I, 40)
GraphZ.DrawLine(PenZ, point1, point2)
Else
PenZ = New Pen(Color.White, 1)
point1 = New Point(I, 15)
point2 = New Point(I, 40)
GraphZ.DrawLine(PenZ, point1, point2)
End If
Next
' رسم النص المراد ترميزه اسفل الكود
GraphZ.DrawString(TheText, New Font("Arial", 8, FontStyle.Regular), New SolidBrush(Color.Black), 0, 40)
GraphZ.DrawString(STR, New Font("Arial", 8, FontStyle.Bold), New SolidBrush(Color.Black), 0, 0)
GraphZ.DrawString(STR1, New Font("Arial", 8, FontStyle.Bold), New SolidBrush(Color.Black), 0, 51)
' ارجاع الصورة النهائية للدالة
Code128 = bmp
End Function
Function Toc(ByVal Text2CStr As String) As String
' دالة لتعويض النص المطلوب تشفيره بالارقام للفئة
' (C)
Dim X As Integer = 1
Dim NewText As String = ""
Dim Z As String = ""
Do
Z = Mid(Text2CStr, X, 2)
' اضافة رقم32 لقيمة الاسكى واستعادة الحرف الناتج بعد الاضافة
NewText = NewText & Chr(Val(Z) + 32)
X += 2
Z = Mid(Text2CStr, X, 1)
If X >= Len(Text2CStr) Then Exit Do
If Z = "" Then Exit Do
Loop
Toc = NewText
End Function
End Class
RE: توسيط سطر معين - محمود صالح - 05-01-18
ارجو المساعدة يا اخوان
RE: توسيط سطر معين - محمود صالح - 05-01-18
شكرا يا اخوان انا لقيت الحل ولمن اراد ان يستفيد
كود :
' انشاء صورة عرضها عدد حروف الباينرى المستخدم
Dim bmp As Bitmap = New Bitmap(Len(Binaryz), 210, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim z As String ' متغير لمعرفة لون الخط
Dim GraphZ As Graphics = Graphics.FromImage(bmp)
Dim RectZ As Rectangle = New Rectangle(0, 0, bmp.Width, bmp.Height) ' مستطيل بحجم الصورة لاعطاء الخلفية باللون الابيض
' فرشاه لدهان المستطيل السابق باللون الابيض
Dim myBrush As Brush = New Drawing.Drawing2D.LinearGradientBrush(RectZ, Color.White, Color.White, Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal)
' دهان المستطيل السابق باللون الابيض
GraphZ.FillRectangle(myBrush, RectZ)
' رسم خطوط الباركود
Dim PenZ As Pen
Dim point1 As Point ' نقطة بداية الخط
Dim point2 As Point ' نقطة نهاية الخط
For I = 1 To Len(Binaryz)
z = Mid(Binaryz, I, 1)
If z = "0" Then
PenZ = New Pen(Color.Black, 1)
point1 = New Point(I, 45)
point2 = New Point(I, 120)
GraphZ.DrawLine(PenZ, point1, point2)
Else
PenZ = New Pen(Color.White, 1)
point1 = New Point(I, 45)
point2 = New Point(I, 120)
GraphZ.DrawLine(PenZ, point1, point2)
End If
Next
' رسم النص المراد ترميزه اسفل الكود
Dim format1 As New StringFormat
format1.Alignment = StringAlignment.Center
GraphZ.DrawString(TheText, New Font("times new roman", 16, FontStyle.Bold), New SolidBrush(Color.Black), bmp.Width / 2, 120, format1)
GraphZ.DrawString(STR, New Font("times new roman", 24, FontStyle.Bold), New SolidBrush(Color.Black), bmp.Width / 2, 0, format1)
GraphZ.DrawString(STR1, New Font("times new roman", 24, FontStyle.Bold), New SolidBrush(Color.Black), bmp.Width / 2, 165, format1)
' ارجاع الصورة النهائية للدالة
Code128 = bmp
RE: توسيط سطر معين - طالب برمجة - 05-01-18
الأفضل استخدام خط مخصص للباركود بدلا من الرسم
RE: توسيط سطر معين - silverlight - 05-01-18
عملية رسم الباركود تحتاج الي بعض الحرفة
في المثال التالي ستجد كودا يوضح كيقية حساب المستطيل الذي يجب أت يحتوي علي الباركود تكست
ايضا الكود يوضح كيفية حساب اأبعاد الصورة
انا استخدمت تشفير بسيط لتحويل الباركود تكست الي Binary أولا
و لم استخدم طريقتك في التشفيير
الكود ممكن تعديله ب اكثر من اسلوب لكي ترسم الباركود والتكست الخاص به
بحيث أن التكست يمكن رسمه في المنتصف او غلي اليمين او علي اليسار تحت اعمدة الباركوود مباشرة
PHP كود :
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Using img As Bitmap = Me.GetBarCode("0123456789", Me.Font) img.Save(".\barCode.jpg") End Using
End Sub
Private Sub GetBarCodeBitmap(barCodeString As String, barCodeFont As Font, ByRef bmp As Bitmap)
Dim pt As Point = New Point(0, 0) Dim ht As Integer = 60 Dim w As Integer = 0 Dim s As String = barCodeString Dim txtSize As Size = TextRenderer.MeasureText(s, Me.Font) Dim result As String = String.Empty
' Convert String to binary Dim i As Integer = 0 While i < s.Length Dim c As Char = s(i) ' encrypt char Dim values As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(c.ToString) Dim j As Integer = 0 While j < values.Length ' convert char to binary use the pattern as per your requirements result += Convert.ToString(values(j), 2).PadLeft(8, "0") j += 1 End While i += 1 End While
Dim penwidth As Single = 2 Dim x As Integer = 0 While x < result.Length w += CInt(penwidth) x += 1 End While
Dim rect As Rectangle = New Rectangle(pt.X, pt.Y + ht, w / 2, txtSize.Height) bmp = New Bitmap(CInt(w / 2), txtSize.Height + ht)
Dim gr As Graphics = Graphics.FromImage(bmp) gr.Clear(Color.White)
Dim mode = gr.SmoothingMode gr.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias Dim m As Integer = 0 While m < result.Length Dim clr As Color = Color.Empty Dim current As String = result(m) If current = "0" Then clr = Color.Black Else clr = Color.White End If
Using p As Pen = New Pen(clr) p.Width = CSng(penwidth) Dim p1 As Point = New Point(m + pt.X, pt.Y) Dim p2 As Point = New Point(m + pt.X, pt.Y + ht) gr.DrawLine(p, p1, p2)
End Using m += 1 End While
Dim contentRect As Rectangle = rect contentRect.Width = txtSize.Width contentRect.X = rect.X + (rect.Width - txtSize.Width) / 2 contentRect.Y = rect.Y + (rect.Height - txtSize.Height) / 2
Using sb As New SolidBrush(Color.Black) gr.DrawString(s, Me.Font, sb, contentRect.X, contentRect.Y) End Using gr.SmoothingMode = mode
If gr IsNot Nothing Then gr.Dispose() gr = Nothing End If
End Sub
Private Function GetBarCode(barcodestring As String, barcodeFont As Font) As Bitmap Dim bmp As Bitmap = CType(Nothing, Bitmap) Me.GetBarCodeBitmap(barcodestring, barcodeFont, bmp) Return bmp End Function
End Class
RE: توسيط سطر معين - محمود صالح - 06-01-18
(05-01-18, 08:09 PM)silverlight كتب : عملية رسم الباركود تحتاج الي بعض الحرفة
في المثال التالي ستجد كودا يوضح كيقية حساب المستطيل الذي يجب أت يحتوي علي الباركود تكست
ايضا الكود يوضح كيفية حساب اأبعاد الصورة
انا استخدمت تشفير بسيط لتحويل الباركود تكست الي Binary أولا
و لم استخدم طريقتك في التشفيير
الكود ممكن تعديله ب اكثر من اسلوب لكي ترسم الباركود والتكست الخاص به
بحيث أن التكست يمكن رسمه في المنتصف او غلي اليمين او علي اليسار تحت اعمدة الباركوود مباشرة
PHP كود :
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Using img As Bitmap = Me.GetBarCode("0123456789", Me.Font) img.Save(".\barCode.jpg") End Using
End Sub
Private Sub GetBarCodeBitmap(barCodeString As String, barCodeFont As Font, ByRef bmp As Bitmap)
Dim pt As Point = New Point(0, 0) Dim ht As Integer = 60 Dim w As Integer = 0 Dim s As String = barCodeString Dim txtSize As Size = TextRenderer.MeasureText(s, Me.Font) Dim result As String = String.Empty
' Convert String to binary Dim i As Integer = 0 While i < s.Length Dim c As Char = s(i) ' encrypt char Dim values As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(c.ToString) Dim j As Integer = 0 While j < values.Length ' convert char to binary use the pattern as per your requirements result += Convert.ToString(values(j), 2).PadLeft(8, "0") j += 1 End While i += 1 End While
Dim penwidth As Single = 2 Dim x As Integer = 0 While x < result.Length w += CInt(penwidth) x += 1 End While
Dim rect As Rectangle = New Rectangle(pt.X, pt.Y + ht, w / 2, txtSize.Height) bmp = New Bitmap(CInt(w / 2), txtSize.Height + ht)
Dim gr As Graphics = Graphics.FromImage(bmp) gr.Clear(Color.White)
Dim mode = gr.SmoothingMode gr.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias Dim m As Integer = 0 While m < result.Length Dim clr As Color = Color.Empty Dim current As String = result(m) If current = "0" Then clr = Color.Black Else clr = Color.White End If
Using p As Pen = New Pen(clr) p.Width = CSng(penwidth) Dim p1 As Point = New Point(m + pt.X, pt.Y) Dim p2 As Point = New Point(m + pt.X, pt.Y + ht) gr.DrawLine(p, p1, p2)
End Using m += 1 End While
Dim contentRect As Rectangle = rect contentRect.Width = txtSize.Width contentRect.X = rect.X + (rect.Width - txtSize.Width) / 2 contentRect.Y = rect.Y + (rect.Height - txtSize.Height) / 2
Using sb As New SolidBrush(Color.Black) gr.DrawString(s, Me.Font, sb, contentRect.X, contentRect.Y) End Using gr.SmoothingMode = mode
If gr IsNot Nothing Then gr.Dispose() gr = Nothing End If
End Sub
Private Function GetBarCode(barcodestring As String, barcodeFont As Font) As Bitmap Dim bmp As Bitmap = CType(Nothing, Bitmap) Me.GetBarCodeBitmap(barcodestring, barcodeFont, bmp) Return bmp End Function
End Class
كود جميل ومختصر ولكن للاسف الطباعة
سيء جدا
هل يمكن انا تجعل الصورة اكثر وضوح
لتكون الطباعة ظاهرة
RE: توسيط سطر معين - silverlight - 08-01-18
هذا أمر عادي لأن الطابعة لها DPI أو لها Resolution يختلف تماما عن الصورة
الأفضل لك هنا هو ن تعيد عملية الرسم في حالة الطباعة
لكن يجب أن ترسم الباركود مباشرة علي ورقة الطباعة و ليس علي صورة
RE: توسيط سطر معين - عبدالله الدوسري - 11-01-18
جرب هذة طريقة مختلفة بإستخدام الخط [ code128.ttf ]
[attachment=16675]
[attachment=16676]
المشروع : [attachment=16677]
يجب تثبيت الخط
ملف الخط : [attachment=16678]
|