Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ใส่ตัวอักษรในภาพ แล้วทำให้เห็น Scroll bar ใน picture box อย่างไรครับ?



 

ใส่ตัวอักษรในภาพ แล้วทำให้เห็น Scroll bar ใน picture box อย่างไรครับ?

 



Topic : 092277



โพสกระทู้ ( 52 )
บทความ ( 0 )



สถานะออฟไลน์




ผมกำลังโปรแกรมใส่ตัวหนังสือลงในรูปภาพ ซึ่งภาพจะย่อขยายตามจำนวนตัวอักษร แต่ติดตรงที่เวลาข้อความยาวๆ หลายๆบรรทัด รูปที่ได้จะเกินหน้าจอ แล้วจะมองไม่เห็นส่วนที่เกินออกไป ทำอย่างไรให้มี scrollbar ใน picture box ครับ?
ผมใส่โค้ด 2 บรรทัดในในอีเวนท์ onload หรือ onclick แล้วก็ยังไม่ได้ครับ (picture box อยู่ใน panel อีกทีครับ)

Code (C#)
this.panel1.AutoScroll = true;
this.picBox.SizeMode = PictureBoxSizeMode.AutoSize;


Code (C#)
private Bitmap CreateBitmapImage(string sImageText)
        {
            this.panel1.AutoScroll = true;
            this.picBox.SizeMode = PictureBoxSizeMode.AutoSize;
            SolidBrush brush = new SolidBrush(Color.FromArgb(FontColor));
            string FileName = "", FilePath;
            if (txtFileName.Text == "")
            {
                FileName = DateTime.Today.ToString("dd ") + DateTime.Today.ToString("MMMM ") + (DateTime.Today.Year + 543).ToString() + " " + DateTime.Now.ToString("HH") + DateTime.Now.ToString("mm") + DateTime.Now.ToString("ss");
            }
            else
                FileName = txtFileName.Text;
            FilePath = txtDirectoryPath.Text + "\\" + FileName + ".jpg";

            Bitmap objBmpImage = new Bitmap(txtDirectoryPath.Text + "\\background.jpg");

            int intWidth = 0;
            int intHeight = 0;

            // Create the Font object for the image text drawing.
            Font objFont = new Font(FontName, FontSize, FontStyle.Regular, GraphicsUnit.Pixel);
            switch (Fontstyle)
            {
                case "Regular": objFont = new Font(FontName, FontSize, FontStyle.Regular, GraphicsUnit.Pixel); break;
                case "Bold": objFont = new Font(FontName, FontSize, FontStyle.Bold, GraphicsUnit.Pixel); break;
                case "Italic": objFont = new Font(FontName, FontSize, FontStyle.Italic, GraphicsUnit.Pixel); break;
                case "Underline": objFont = new Font(FontName, FontSize, FontStyle.Underline, GraphicsUnit.Pixel); break;
                case "Bold, Italic": objFont = new Font(FontName, FontSize, FontStyle.Italic | FontStyle.Bold, GraphicsUnit.Pixel); break;
            }

            // Create a graphics object to measure the text's width and height.
            Graphics objGraphics = Graphics.FromImage(objBmpImage);

            // This is where the bitmap size is determined.
            intWidth = (int)objGraphics.MeasureString(sImageText, objFont).Width + 15;
            intHeight = (int)objGraphics.MeasureString(sImageText, objFont).Height + 15;

            // Create the bmpImage again with the correct size for the text and font.
            objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));

            StringFormat strFormat = new StringFormat();
            switch(Alignment)
            {
                case "Left": strFormat.Alignment = StringAlignment.Near; break;
                case "Center": strFormat.Alignment = StringAlignment.Center; break;
                case "Right": strFormat.Alignment = StringAlignment.Far; break;
                default: break;
            }
            switch (LineAlignment)
            {
                case "Top": strFormat.LineAlignment = StringAlignment.Near; break;
                case "Center": strFormat.LineAlignment = StringAlignment.Center; break;
                case "Bottom": strFormat.LineAlignment = StringAlignment.Far; break;
                default: break;
            }

            // Add the colors to the new bitmap.
            objGraphics = Graphics.FromImage(objBmpImage);

            // Set Background color
            if(rdoColorBack.Checked)
                objGraphics.Clear(Color.FromArgb(BackgroundColor));
            objGraphics.SmoothingMode = SmoothingMode.HighQuality;

            //objGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; //  <-- This is the correct value to use. ClearTypeGridFit is better yet!
            objGraphics.DrawString(sImageText, objFont, brush, new RectangleF(0,0,intWidth,intHeight), strFormat /*StringFormat.GenericDefault*/);

            objGraphics.Flush();
            objBmpImage.Save(FilePath);
            return (objBmpImage);
        }




Tag : .NET, Win (Windows App), C#, VS 2010 (.NET 4.x), Windows







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-03-12 13:31:33 By : snowbell View : 1346 Reply : 2
 

 

No. 1

Guest


เอา picturebox ใส่ panel ด้วย dock แบบ fill

เวลามันล้นจะมี scroll bar ของ panel ให้เห็น






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-12 16:34:12 By : ห้ามตอบเกินวันละ 2 กระทู้
 


 

No. 2



โพสกระทู้ ( 52 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : ห้ามตอบเกินวันละ 2 กระทู้ เมื่อวันที่ 2013-03-12 16:34:12
รายละเอียดของการตอบ ::
ยังไม่ได้ครับ
เอา picture box ใส่ใน panel แล้ว
picturebox ตั้งให้ dock เป็นแบบ fill



ประวัติการแก้ไข
2013-03-12 16:57:12
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-12 16:45:10 By : snowbell
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ใส่ตัวอักษรในภาพ แล้วทำให้เห็น Scroll bar ใน picture box อย่างไรครับ?
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่