注册 登录
编程论坛 C语言论坛

求助:DrawString 函数

追梦人zmrghy 发布于 2022-07-22 20:43, 1343 次点击
求助:DrawString 函数, 如何输出如图效果。。。。。

只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录



只有本站会员才能查看附件,请 登录


程序代码:
private: Void draw_num_str(Point^ inpoint, int wide, int num)
    {
        Image^ drawimg = gcnew Bitmap(wide, wide);
        Graphics^ g = Graphics::FromImage(drawimg);
        SolidBrush^ MyBrush = gcnew SolidBrush(Color::Cyan);
        g->FillRectangle(MyBrush, Rectangle(inpoint->X + wide / 20, inpoint->Y + wide / 20, (wide * 9) / 10, (wide * 9) / 10));
        MyBrush->Color = Color::Black;
        g->FillEllipse(MyBrush, Rectangle(inpoint->X + wide / 10, inpoint->Y + wide / 10, (wide * 4) / 5, (wide * 4) / 5));
        
        MyBrush->Color = Color::Cyan;
        
        /*-----------------------------------------------
            此处是 DrawString 绘制数字,字符串的地方
            6个 DrawString 函数,应该使用哪一个。
            实现,如图效果,代码应该如何写。。。。
        ------------------------------------------------
*/
        
        this->pictureBox1->Image = drawimg;
    }
    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
    {
        draw_num_str(Point(0, 0), 200, 9999);
    }



DrawString 函数, 如何输出如图效果。。。。。
6个 DrawString 函数,应该使用哪一个。
实现,如图效果,代码应该如何写。。。。

[此贴子已经被作者于2022-7-22 20:45编辑过]

9 回复
#2
追梦人zmrghy2022-07-23 13:03
为什么,都不回答我的问题呀???
#3
op1232022-07-23 15:19
我看看
#4
op1232022-07-23 15:22
你把所有代码都发出来
#5
op1232022-07-23 15:23
你这个是图形算法吧
#6
op1232022-07-23 15:24
我还有事,明天来!!!
#7
op1232022-07-23 15:24
别忘了发出来代码
#8
追梦人zmrghy2022-07-23 17:35
回复 7楼 op123
只有本站会员才能查看附件,请 登录


VS2022  C++/CLR  Winform.
#9
op1232022-07-24 18:44
麻烦打出来代码,我家旧电脑打开不方便,我家电脑版本低
#10
追梦人zmrghy2022-07-25 00:58
回复 9楼 op123
程序代码:
#pragma once

namespace DrawNumberString {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    /// <summary>
   
/// Form1 摘要
   
/// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            
//TODO:  在此处添加构造函数代码
            
//
        }

    protected:
        /// <summary>
        
/// 清理所有正在使用的资源。
        
/// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::PictureBox^ pictureBox1;
    private: System::Windows::Forms::Button^ button1;
    protected:

    private:
        /// <summary>
        
/// 必需的设计器变量。
        
/// </summary>
        System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
        /// <summary>
        
/// 设计器支持所需的方法 - 不要修改
        
/// 使用代码编辑器修改此方法的内容。
        
/// </summary>
        void InitializeComponent(void)
        {
            this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
            this->SuspendLayout();
            //
            
// pictureBox1
            
//
            this->pictureBox1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(224)),
                static_cast<System::Int32>(static_cast<System::Byte>(192)));
            this->pictureBox1->Location = System::Drawing::Point(0, 0);
            this->pictureBox1->Name = L"pictureBox1";
            this->pictureBox1->Size = System::Drawing::Size(200, 200);
            this->pictureBox1->TabIndex = 0;
            this->pictureBox1->TabStop = false;
            //
            
// button1
            
//
            this->button1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
                static_cast<System::Int32>(static_cast<System::Byte>(0)));
            this->button1->Font = (gcnew System::Drawing::Font(L"宋体", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(134)));
            this->button1->ForeColor = System::Drawing::Color::Blue;
            this->button1->Location = System::Drawing::Point(48, 203);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(104, 39);
            this->button1->TabIndex = 1;
            this->button1->Text = L"D R A W";
            this->button1->UseVisualStyleBackColor = false;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            //
            
// Form1
            
//
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(200, 246);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->pictureBox1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
            this->ResumeLayout(false);

        }
#pragma endregion
    private: Void draw_num_str(Point^ inpoint, int wide, int num)
    {
        Image^ drawimg = gcnew Bitmap(wide, wide);
        Graphics^ g = Graphics::FromImage(drawimg);
        SolidBrush^ MyBrush = gcnew SolidBrush(Color::Cyan);
        g->FillRectangle(MyBrush, Rectangle(inpoint->X + wide / 20, inpoint->Y + wide / 20, (wide * 9) / 10, (wide * 9) / 10));
        MyBrush->Color = Color::Black;
        g->FillEllipse(MyBrush, Rectangle(inpoint->X + wide / 10, inpoint->Y + wide / 10, (wide * 4) / 5, (wide * 4) / 5));
        
        MyBrush->Color = Color::Cyan;
        
        /*-----------------------------------------------
            此处是 DrawString 绘制数字,字符串的地方
            6个 DrawString 函数,应该使用哪一个。
            实现,如图效果,代码应该如何写。。。。
        ------------------------------------------------
*/

        this->pictureBox1->Image = drawimg;
    }
    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
    {
        draw_num_str(Point(0, 0), 200, 9999);
    }
    };
}
1