C#實(shí)現(xiàn)將像素轉(zhuǎn)換為頁(yè)面單位的方法
更新時(shí)間:2015年06月12日 11:07:37 作者:zhuzhao
這篇文章主要介紹了C#實(shí)現(xiàn)將像素轉(zhuǎn)換為頁(yè)面單位的方法,涉及C#像素轉(zhuǎn)換在圖形繪制中的技巧,需要的朋友可以參考下
本文實(shí)例講述了C#實(shí)現(xiàn)將像素轉(zhuǎn)換為頁(yè)面單位的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace advanced_drawing
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
g.PageUnit = GraphicsUnit.Inch;
g.PageScale = 1;
PointF[] bottomRight = new PointF[] { new PointF(this.ClientSize.Width, this.ClientSize.Height) };
g.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device, bottomRight);
Rectangle rect = new Rectangle(0, 0, 10, 10);
Pen pen=new Pen(Color.Red);
g.DrawRectangle(pen, rect);
}
}
}
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
讓C# Excel導(dǎo)入導(dǎo)出 支持不同版本Office
讓C# Excel導(dǎo)入導(dǎo)出,支持不同版本的Office,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-08-08
C#使用OpenCvSharp實(shí)現(xiàn)圖像校正
這篇文章主要為大家詳細(xì)介紹了C#如何使用OpenCvSharp實(shí)現(xiàn)圖像校正功能,文中的示例代碼簡(jiǎn)潔易懂,具有一定的學(xué)習(xí)價(jià)值,需要的小伙伴可以參考下2023-11-11
unity實(shí)現(xiàn)簡(jiǎn)單計(jì)算器
這篇文章主要為大家詳細(xì)介紹了unity實(shí)現(xiàn)簡(jiǎn)單計(jì)算器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08
C# GetMethod方法的應(yīng)用實(shí)例講解
GetMethod 是獲取當(dāng)前 Type 的特定方法,具有多個(gè)重載, GetMethod 即使用指定的綁定約束搜索指定方法,本文給大家介紹了C# GetMethod方法的應(yīng)用實(shí)例,需要的朋友可以參考下2024-04-04

