الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

طلب كود تحويل النص الى صوره

بدأه dly في 28 أبريل 2014 · 3 رد · 730 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

 

عندي مشروع تخرج وجالسه اشتغل عليه بلغة asp.net ابغى كود تحويل النص الى صوره يعني ياخذ النص الي بالتكست بوكس و كاوت بوت يطلعلي صوره بدال النص

#2

بسم الله الرحمن الرحيم

 

اختى الكود ده ان شاء الله يفيدك

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Public Shared Sub Convert_Text_to_Image(ByVal txt As String, ByVal fontname As String, ByVal fontsize As Integer, ByVal path As String)
        Dim bmp As New Bitmap(1, 1)

       
        Dim graphics__1 As Graphics = Graphics.FromImage(bmp)
       
        Dim font As New Font(fontname, fontsize)
      
        Dim stringSize As SizeF = graphics__1.MeasureString(txt, font)
        bmp = New Bitmap(bmp, CInt(stringSize.Width), CInt(stringSize.Height))
        graphics__1 = Graphics.FromImage(bmp)



     
        graphics__1.DrawString(txt, font, Brushes.Red, 0, 0)
        font.Dispose()
        graphics__1.Flush()
        graphics__1.Dispose()
        bmp.Save(path)

      
    End Sub

    Private Sub btnconvert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Convert_Text_to_Image(txtvalue.Text, "Bookman Old Style", 20, Server.MapPath("\Images\1.bmp"))
        picbox.ImageUrl = ("~\Images\1.bmp")
  End Sub

جربى و رد على

تم تعديل هذه المشاركة بواسطة bodaman22 في 29 أبريل 2014 في 08:35

1
#3

وعليكم السلام ورحمة الله وبركاته الكود ب c#

        public Color FontColor { get; set; }
        public Color FontBackColor { get; set; }
        public string FontName { get; set; }
        public string ImagePath { get; set; }
        public int FontSize { get; set; }
        public int ImageHeight { get; set; }
        public int ImageWidth { get; set; }
        public Bitmap ImageText { get; set; }
        public Graphics ImageGraphics { get; set; }
        public Font ImageFont { get; set; }
        public SolidBrush BrushForeColor { get; set; }
        public SolidBrush BrushBackColor { get; set; }
        public PointF ImagePointF { get; set; }

        private void DrawText(string text)
        {
            FontColor = Color.Red;
            FontBackColor = Color.Yellow;
            FontName = "Arial";
            FontSize = 10;
            ImageHeight = textBox1.Height;
            ImageWidth = textBox1.Width;
                        //saveimage in bin of the project with textbox name content
            ImagePath = Application.StartupPath + "\\" + textBox1.Text + ".JPEG";

            //this for save image in ecery place you need ..Name of image ==textbox value
             //ImagePath =  @"C:\"+textBox1 .Text +".JPEG";

            ImageText = new Bitmap(ImageWidth, ImageHeight);

            ImageGraphics = Graphics.FromImage(ImageText);

            ImageFont = new Font(FontName, FontSize);
            ImagePointF = new PointF(5, 5);
            BrushForeColor = new SolidBrush(FontColor);
            BrushBackColor = new SolidBrush(FontBackColor);

            ImageGraphics.FillRectangle(BrushBackColor, 0, 0, ImageWidth, ImageHeight);
            ImageGraphics.DrawString(text, ImageFont, BrushForeColor, ImagePointF);

            ImageText.Save(ImagePath, ImageFormat.Jpeg);
        }


        private void button1_Click(object sender, EventArgs e)
        {
            DrawText(textBox1.Text);
        }

ادخال ارقام فقط فى TextBox


http://consoledotread.blogspot.com/2014/03/allow-textbox-accept-only-number-c.html


--


مثال بسيط للبحث داخل الداتا بيز واسترجاع النتائج داخل textboxs


https://consoledotread.blogspot.com/b/post-preview?token=QAU8sEUBAAA.SS_bsuZGwEBtU1HK3qRljA.HsnvAY7IlWKbUW9D0jvLQg&postId=2256449426535795254&type=POST


 


--


 


سبحان الله وبحمده***سبحان الله العظيم


#4
bodaman22 كتب:

بسم الله الرحمن الرحيم

 

اختى الكود ده ان شاء الله يفيدك

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Public Shared Sub Convert_Text_to_Image(ByVal txt As String, ByVal fontname As String, ByVal fontsize As Integer, ByVal path As String)
        Dim bmp As New Bitmap(1, 1)

       
        Dim graphics__1 As Graphics = Graphics.FromImage(bmp)
       
        Dim font As New Font(fontname, fontsize)
      
        Dim stringSize As SizeF = graphics__1.MeasureString(txt, font)
        bmp = New Bitmap(bmp, CInt(stringSize.Width), CInt(stringSize.Height))
        graphics__1 = Graphics.FromImage(bmp)



     
        graphics__1.DrawString(txt, font, Brushes.Red, 0, 0)
        font.Dispose()
        graphics__1.Flush()
        graphics__1.Dispose()
        bmp.Save(path)

      
    End Sub

    Private Sub btnconvert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Convert_Text_to_Image(txtvalue.Text, "Bookman Old Style", 20, Server.MapPath("\Images\1.bmp"))
        picbox.ImageUrl = ("~\Images\1.bmp")
  End Sub

جربى و رد على

صراحه مافهمت الكود الي كاتبه لكن الحمدالله جربت كود ثاني وضبط معاي شكرا على المساعده

تم تعديل هذه المشاركة بواسطة dly في 3 مايو 2014 في 21:24

مواضيع مشابهة