一、老规矩,先看效果:
1、原图一
生成效果图一:
2、原图二
生成效果图二:
3、原图三:
生成效果图三之1:
效果图三之2:
说明:图三中同样的原图,生成的ASCII字符串大小不同,因为所取参数不同。
二、关键源代码:
// 调整行距: AdjustLineSpace.cs
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace Com.BrawDraw.Controls.Helper
{
public static class AdjustLineSpace
{
public const int WM_USER = 0x0400;
public const int EM_GETPARAFORMAT = WM_USER + 61;
public const int EM_SETPARAFORMAT = WM_USER + 71;
public const long MAX_TAB_STOPS = 32;
public const uint PFM_LINESPACING = 0x00000100;
[StructLayout(LayoutKind.Sequential)]
private struct PARAFORMAT2
{
public int cbSize;
public uint dwMask;
public short wNumbering;
public short wReserved;
public int dxStartIndent;
public int dxRightIndent;
public int dxOffset;
public short wAlignment;
public short cTabCount;
[MarshalAs(UnmanagedType.