文档章节

Direct2D (39) : 使用 IDWriteTextLayout.Draw() 方法绘制文本

涂孟超
 涂孟超
发布于 2014/09/26 15:37
字数 1164
阅读 6
收藏 0
点赞 0
评论 0

使用 IDWriteTextLayout.Draw() 方法绘制文本主要是实现 IDWriteTextRenderer 接口。
IDWriteTextRenderer 接口只能是手动实现,很灵活。

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Direct2D, D2D1;

type
  TForm1 = class(TForm)
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
  end;

  TMyWriteTextRenderer = class(TInterfacedObject, IDWriteTextRenderer)
  private
    FRenderTarge: ID2D1RenderTarget;
    FOutLineBrush,FFillBrush: ID2D1Brush;
  public
    constructor Create(ARenderTarge: ID2D1RenderTarget; AOutLineBrush,AFillBrush: ID2D1Brush);
    function IsPixelSnappingDisabled(clientDrawingContext: Pointer; var isDisabled: LongBool): HRESULT;
      stdcall;
    function GetCurrentTransform(clientDrawingContext: Pointer; var transform: DWRITE_MATRIX): HRESULT;
      stdcall;
    function GetPixelsPerDip(clientDrawingContext: Pointer; var pixelsPerDip: Single): HRESULT; stdcall;
    function DrawGlyphRun(clientDrawingContext: Pointer; baselineOriginX: Single; baselineOriginY: Single;
      measuringMode: DWRITE_MEASURING_MODE; var glyphRun: DWRITE_GLYPH_RUN;
      var glyphRunDescription: DWRITE_GLYPH_RUN_DESCRIPTION; const clientDrawingEffect: IInterface): HRESULT;
      stdcall;
    function DrawUnderline(clientDrawingContext: Pointer; baselineOriginX: Single; baselineOriginY: Single;
      var underline: DWRITE_UNDERLINE; const clientDrawingEffect: IInterface): HRESULT; stdcall;
    function DrawStrikethrough(clientDrawingContext: Pointer; baselineOriginX: Single;
      baselineOriginY: Single; var strikethrough: DWRITE_STRIKETHROUGH;
      const clientDrawingEffect: IInterface): HRESULT; stdcall;
    function DrawInlineObject(clientDrawingContext: Pointer; originX: Single; originY: Single;
      var inlineObject: IDWriteInlineObject; isSideways: LongBool; isRightToLeft: LongBool;
      const clientDrawingEffect: IInterface): HRESULT; stdcall;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


{构建 DWRITE_TEXT_RANGE 结构的函数}
function DWriteTextRange(pos,len: Cardinal): TDwriteTextRange;
begin
  Result.startPosition := pos;
  Result.length := len;
end;

{构建 DWRITE_FONT_FEATURE 结构的函数}
function DWriteFontFeature(nameTag: Integer; parameter: Cardinal): TDwriteFontFeature;
begin
  Result.nameTag := nameTag;
  Result.parameter := parameter;
end;

{建立位图画刷的函数}
function GetBitmapBrush(Canvas: TDirect2DCanvas; filePath: string): ID2D1BitmapBrush;
var
  rBBP: TD2D1BitmapBrushProperties;
  bit: TBitmap;
begin
  bit := TBitmap.Create;
  bit.LoadFromFile(filePath);
  rBBP.extendModeX := D2D1_EXTEND_MODE_WRAP;
  rBBP.extendModeY := D2D1_EXTEND_MODE_WRAP;
  rBBP.interpolationMode := D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
  Canvas.RenderTarget.CreateBitmapBrush(Canvas.CreateBitmap(bit), @rBBP, nil, Result);
  bit.Free;
end;

procedure TForm1.FormPaint(Sender: TObject);
var
  cvs: TDirect2DCanvas;
  str: string;
  iTextFormat: IDWriteTextFormat;
  iSolidColorBrush: ID2D1SolidColorBrush;
  iBitmapBrush: ID2D1BitmapBrush;
  iTextLayout: IDWriteTextLayout;
  iTypography: IDWriteTypography;
  iTextRenderer: IDWriteTextRenderer;
begin
  str := 'Hello World using DirectWrite!';
  DWriteFactory.CreateTextFormat(
    'Gabriola',
    nil,
    DWRITE_FONT_WEIGHT_REGULAR,
    DWRITE_FONT_STYLE_NORMAL,
    DWRITE_FONT_STRETCH_NORMAL,
    72.0,
    'en-us',
    iTextFormat
  );
  iTextFormat.SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
  iTextFormat.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);

  DWriteFactory.CreateTextLayout(
    PWideChar(str),
    Length(str),
    iTextFormat,
    ClientWidth,
    ClientHeight,
    iTextLayout
  );

  iTextLayout.SetFontSize(100.0, DWriteTextRange(18, 6));
  iTextLayout.SetUnderline(True, DWriteTextRange(18, 11));
  iTextLayout.SetFontWeight(DWRITE_FONT_WEIGHT_BOLD, DWriteTextRange(18, 11));

  DWriteFactory.CreateTypography(iTypography);
  iTypography.AddFontFeature(DWriteFontFeature(DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6, 1));
  iTextLayout.SetTypography(iTypography, DWriteTextRange(0, Length(str)));

  cvs := TDirect2DCanvas.Create(Canvas, ClientRect);
  cvs.RenderTarget.CreateSolidColorBrush(D2D1ColorF(clBlack), nil, iSolidColorBrush);
  iBitmapBrush := GetBitmapBrush(cvs, 'C:\Temp\Test.bmp');
  iTextRenderer := TMyWriteTextRenderer.Create(cvs.RenderTarget, iSolidColorBrush, iBitmapBrush);
  cvs.RenderTarget.BeginDraw;
  cvs.RenderTarget.Clear(D2D1ColorF(clWhite));
  iTextLayout.Draw(nil, iTextRenderer, 0, 0);
  cvs.RenderTarget.EndDraw();
  cvs.Free;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  Repaint;
end;

{ TMyWriteTextRenderer }

constructor TMyWriteTextRenderer.Create(ARenderTarge: ID2D1RenderTarget; AOutLineBrush,
  AFillBrush: ID2D1Brush);
begin
  FRenderTarge := ARenderTarge;
  FOutLineBrush := AOutLineBrush;
  FFillBrush := AFillBrush;
end;

function TMyWriteTextRenderer.DrawGlyphRun(clientDrawingContext: Pointer; baselineOriginX,
  baselineOriginY: Single; measuringMode: DWRITE_MEASURING_MODE; var glyphRun: DWRITE_GLYPH_RUN;
  var glyphRunDescription: DWRITE_GLYPH_RUN_DESCRIPTION; const clientDrawingEffect: IInterface): HRESULT;
var
  iPathGeometry: ID2D1PathGeometry;
  iGeometrySink: ID2D1GeometrySink;
  iTransformedGeometry: ID2D1TransformedGeometry;
begin
  D2DFactory.CreatePathGeometry(iPathGeometry);
  iPathGeometry.Open(iGeometrySink);
  glyphRun.fontFace.GetGlyphRunOutline(
    glyphRun.fontEmSize,
    glyphRun.glyphIndices,
    glyphRun.glyphAdvances,
    glyphRun.glyphOffsets,
    glyphRun.glyphCount,
    glyphRun.isSideways,
    longBool(glyphRun.bidiLevel div 2),
    iGeometrySink
  );
  iGeometrySink.Close;

  D2DFactory.CreateTransformedGeometry(
    iPathGeometry,
    TD2DMatrix3x2F.Translation(baselineOriginX, baselineOriginY),
    iTransformedGeometry
  );

  FRenderTarge.DrawGeometry(iTransformedGeometry, FOutLineBrush);
  FRenderTarge.FillGeometry(iTransformedGeometry, FFillBrush);
  Result := S_OK;
end;

function TMyWriteTextRenderer.DrawInlineObject(clientDrawingContext: Pointer; originX, originY: Single;
  var inlineObject: IDWriteInlineObject; isSideways, isRightToLeft: LongBool;
  const clientDrawingEffect: IInterface): HRESULT;
begin
  Result := E_NOTIMPL; //未实现
end;

function TMyWriteTextRenderer.DrawStrikethrough(clientDrawingContext: Pointer; baselineOriginX,
  baselineOriginY: Single; var strikethrough: DWRITE_STRIKETHROUGH;
  const clientDrawingEffect: IInterface): HRESULT;
var
  rRectF: TD2DRectF;
  iRectangleGeometry: ID2D1RectangleGeometry;
  iTransformedGeometry: ID2D1TransformedGeometry;
begin
  rRectF := D2D1RectF(
    0,
    strikethrough.offset,
    strikethrough.width,
    strikethrough.offset + strikethrough.thickness
  );

  D2DFactory.CreateRectangleGeometry(rRectF, iRectangleGeometry);
  D2DFactory.CreateTransformedGeometry(
    iRectangleGeometry,
    TD2DMatrix3x2F.Translation(baselineOriginX, baselineOriginY),
    iTransformedGeometry
  );

  FRenderTarge.DrawGeometry(iTransformedGeometry, FOutLineBrush);
  FRenderTarge.FillGeometry(iTransformedGeometry, FFillBrush);
  Result := S_OK;
end;

function TMyWriteTextRenderer.DrawUnderline(clientDrawingContext: Pointer; baselineOriginX,
  baselineOriginY: Single; var underline: DWRITE_UNDERLINE; const clientDrawingEffect: IInterface): HRESULT;
var
  rRectF: TD2DRectF;
  iRectangleGeometry: ID2D1RectangleGeometry;
  iTransformedGeometry: ID2D1TransformedGeometry;
begin
  rRectF := D2D1RectF(
    0,
    underline.offset,
    underline.width,
    underline.offset + underline.thickness
  );

  D2DFactory.CreateRectangleGeometry(rRectF, iRectangleGeometry);
  D2DFactory.CreateTransformedGeometry(
    iRectangleGeometry,
    TD2DMatrix3x2F.Translation(baselineOriginX, baselineOriginY),
    iTransformedGeometry
  );

  FRenderTarge.DrawGeometry(iTransformedGeometry, FOutLineBrush);
  FRenderTarge.FillGeometry(iTransformedGeometry, FFillBrush);
  Result := S_OK;
end;

function TMyWriteTextRenderer.GetCurrentTransform(clientDrawingContext: Pointer;
  var transform: DWRITE_MATRIX): HRESULT;
begin
  FRenderTarge.GetTransform(TD2D1Matrix3x2F(transform));
  Result := S_OK;
end;

function TMyWriteTextRenderer.GetPixelsPerDip(clientDrawingContext: Pointer;
  var pixelsPerDip: Single): HRESULT;
var
  x,y: Single;
begin
  FRenderTarge.GetDpi(x, y);
  pixelsPerDip := x / 96;
  Result := S_OK;
end;

function TMyWriteTextRenderer.IsPixelSnappingDisabled(clientDrawingContext: Pointer;
  var isDisabled: LongBool): HRESULT;
begin
  isDisabled := False;
  Result := S_OK;
end;

end.


效果图:



简化一下,只描绘文本的轮廓:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Direct2D, D2D1;

type
  TForm1 = class(TForm)
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
  end;

  TMyWriteTextRenderer = class(TInterfacedObject, IDWriteTextRenderer)
  private
    FRenderTarge: ID2D1RenderTarget;
    FOutLineBrush: ID2D1Brush;
  public
    constructor Create(ARenderTarge: ID2D1RenderTarget; AOutLineBrush: ID2D1Brush);
    function IsPixelSnappingDisabled(clientDrawingContext: Pointer; var isDisabled: LongBool): HRESULT;
      stdcall;
    function GetCurrentTransform(clientDrawingContext: Pointer; var transform: DWRITE_MATRIX): HRESULT;
      stdcall;
    function GetPixelsPerDip(clientDrawingContext: Pointer; var pixelsPerDip: Single): HRESULT; stdcall;
    function DrawGlyphRun(clientDrawingContext: Pointer; baselineOriginX: Single; baselineOriginY: Single;
      measuringMode: DWRITE_MEASURING_MODE; var glyphRun: DWRITE_GLYPH_RUN;
      var glyphRunDescription: DWRITE_GLYPH_RUN_DESCRIPTION; const clientDrawingEffect: IInterface): HRESULT;
      stdcall;
    function DrawUnderline(clientDrawingContext: Pointer; baselineOriginX: Single; baselineOriginY: Single;
      var underline: DWRITE_UNDERLINE; const clientDrawingEffect: IInterface): HRESULT; stdcall;
    function DrawStrikethrough(clientDrawingContext: Pointer; baselineOriginX: Single;
      baselineOriginY: Single; var strikethrough: DWRITE_STRIKETHROUGH;
      const clientDrawingEffect: IInterface): HRESULT; stdcall;
    function DrawInlineObject(clientDrawingContext: Pointer; originX: Single; originY: Single;
      var inlineObject: IDWriteInlineObject; isSideways: LongBool; isRightToLeft: LongBool;
      const clientDrawingEffect: IInterface): HRESULT; stdcall;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


{构建 DWRITE_TEXT_RANGE 结构的函数}
function DWriteTextRange(pos,len: Cardinal): TDwriteTextRange;
begin
  Result.startPosition := pos;
  Result.length := len;
end;

{构建 DWRITE_FONT_FEATURE 结构的函数}
function DWriteFontFeature(nameTag: Integer; parameter: Cardinal): TDwriteFontFeature;
begin
  Result.nameTag := nameTag;
  Result.parameter := parameter;
end;

procedure TForm1.FormPaint(Sender: TObject);
var
  cvs: TDirect2DCanvas;
  str: string;
  iTextFormat: IDWriteTextFormat;
  iSolidColorBrush: ID2D1SolidColorBrush;
  iTextLayout: IDWriteTextLayout;
  iTypography: IDWriteTypography;
  iTextRenderer: IDWriteTextRenderer;
begin
  str := 'Hello World using DirectWrite!';
  DWriteFactory.CreateTextFormat(
    'Gabriola',
    nil,
    DWRITE_FONT_WEIGHT_ULTRA_BLACK,
    DWRITE_FONT_STYLE_NORMAL,
    DWRITE_FONT_STRETCH_NORMAL,
    72.0,
    'en-us',
    iTextFormat
  );
  iTextFormat.SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
  iTextFormat.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);

  DWriteFactory.CreateTextLayout(
    PWideChar(str),
    Length(str),
    iTextFormat,
    ClientWidth,
    ClientHeight,
    iTextLayout
  );

  iTextLayout.SetFontSize(100.0, DWriteTextRange(18, 6));
  iTextLayout.SetUnderline(True, DWriteTextRange(18, 11));
  iTextLayout.SetFontWeight(DWRITE_FONT_WEIGHT_BOLD, DWriteTextRange(18, 11));

  DWriteFactory.CreateTypography(iTypography);
  iTypography.AddFontFeature(DWriteFontFeature(DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6, 1));
  iTextLayout.SetTypography(iTypography, DWriteTextRange(0, Length(str)));

  cvs := TDirect2DCanvas.Create(Canvas, ClientRect);
  cvs.RenderTarget.CreateSolidColorBrush(D2D1ColorF(clRed), nil, iSolidColorBrush);
  iTextRenderer := TMyWriteTextRenderer.Create(cvs.RenderTarget, iSolidColorBrush);
  cvs.RenderTarget.BeginDraw;
  cvs.RenderTarget.Clear(D2D1ColorF(clWhite));
  iTextLayout.Draw(nil, iTextRenderer, 0, 0);
  cvs.RenderTarget.EndDraw();
  cvs.Free;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  Repaint;
end;

{ TMyWriteTextRenderer }

constructor TMyWriteTextRenderer.Create(ARenderTarge: ID2D1RenderTarget; AOutLineBrush: ID2D1Brush);
begin
  FRenderTarge := ARenderTarge;
  FOutLineBrush := AOutLineBrush;
end;

function TMyWriteTextRenderer.DrawGlyphRun(clientDrawingContext: Pointer; baselineOriginX,
  baselineOriginY: Single; measuringMode: DWRITE_MEASURING_MODE; var glyphRun: DWRITE_GLYPH_RUN;
  var glyphRunDescription: DWRITE_GLYPH_RUN_DESCRIPTION; const clientDrawingEffect: IInterface): HRESULT;
var
  iPathGeometry: ID2D1PathGeometry;
  iGeometrySink: ID2D1GeometrySink;
  iTransformedGeometry: ID2D1TransformedGeometry;
begin
  D2DFactory.CreatePathGeometry(iPathGeometry);
  iPathGeometry.Open(iGeometrySink);
  glyphRun.fontFace.GetGlyphRunOutline(
    glyphRun.fontEmSize,
    glyphRun.glyphIndices,
    glyphRun.glyphAdvances,
    glyphRun.glyphOffsets,
    glyphRun.glyphCount,
    glyphRun.isSideways,
    longBool(glyphRun.bidiLevel div 2),
    iGeometrySink
  );
  iGeometrySink.Close;

  D2DFactory.CreateTransformedGeometry(
    iPathGeometry,
    TD2DMatrix3x2F.Translation(baselineOriginX, baselineOriginY),
    iTransformedGeometry
  );

  FRenderTarge.DrawGeometry(iTransformedGeometry, FOutLineBrush);
  Result := S_OK;
end;

function TMyWriteTextRenderer.DrawInlineObject(clientDrawingContext: Pointer; originX, originY: Single;
  var inlineObject: IDWriteInlineObject; isSideways, isRightToLeft: LongBool;
  const clientDrawingEffect: IInterface): HRESULT;
begin
  Result := E_NOTIMPL;
end;

function TMyWriteTextRenderer.DrawStrikethrough(clientDrawingContext: Pointer; baselineOriginX,
  baselineOriginY: Single; var strikethrough: DWRITE_STRIKETHROUGH;
  const clientDrawingEffect: IInterface): HRESULT;
begin
  Result := E_NOTIMPL;
end;

function TMyWriteTextRenderer.DrawUnderline(clientDrawingContext: Pointer; baselineOriginX,
  baselineOriginY: Single; var underline: DWRITE_UNDERLINE; const clientDrawingEffect: IInterface): HRESULT;
var
  rRectF: TD2DRectF;
  iRectangleGeometry: ID2D1RectangleGeometry;
  iTransformedGeometry: ID2D1TransformedGeometry;
begin
  rRectF := D2D1RectF(
    0,
    underline.offset,
    underline.width,
    underline.offset + underline.thickness
  );

  D2DFactory.CreateRectangleGeometry(rRectF, iRectangleGeometry);
  D2DFactory.CreateTransformedGeometry(
    iRectangleGeometry,
    TD2DMatrix3x2F.Translation(baselineOriginX, baselineOriginY),
    iTransformedGeometry
  );

  FRenderTarge.DrawGeometry(iTransformedGeometry, FOutLineBrush);
  Result := S_OK;
end;

function TMyWriteTextRenderer.GetCurrentTransform(clientDrawingContext: Pointer;
  var transform: DWRITE_MATRIX): HRESULT;
begin
  FRenderTarge.GetTransform(TD2D1Matrix3x2F(transform));
  Result := S_OK;
end;

function TMyWriteTextRenderer.GetPixelsPerDip(clientDrawingContext: Pointer;
  var pixelsPerDip: Single): HRESULT;
var
  x,y: Single;
begin
  FRenderTarge.GetDpi(x, y);
  pixelsPerDip := x / 96;
  Result := S_OK;
end;

function TMyWriteTextRenderer.IsPixelSnappingDisabled(clientDrawingContext: Pointer;
  var isDisabled: LongBool): HRESULT;
begin
  isDisabled := False;
  Result := S_OK;
end;

end.


效果图:



本文转载自:http://www.cnblogs.com/del/archive/2011/04/13/2014946.html

共有 人打赏支持
涂孟超
粉丝 12
博文 2004
码字总数 14107
作品 0
深圳
程序员
Direct2D教程(十)绘制文本

概述 在Direct2D中,文本的绘制是通过DirectWrite来实现的,DirectWrite实际上已经是一个独立的DirectX组件了。关于DirectWrite,我摘录了MSDN的一段文字。 DirectWrite介绍 当今的应用程序应...

吞吞吐吐的 ⋅ 2017/10/17 ⋅ 0

WPF 使用 Direct2D1 画图 绘制基本图形

本文来告诉大家如何在 Direct2D1 绘制基本图形,包括线段、矩形、椭圆 本文是一个系列 WPF 使用 Direct2D1 画图入门 WPF 使用 Direct2D1 画图 绘制基本图形 本文的组织参考Direct2D,对大神表...

lindexi_gd ⋅ 04/19 ⋅ 0

Windows桌面应用程序(1-2-4-7th) DPI和设备无关的像素

要使用Windows图形进行有效编程,您必须了解两个相关的概念: 每英寸点数(DPI) 设备无关像素(DIP)。 我们从DPI开始。这将需要短暂的绕行排版。在印刷术中,类型的大小以称为点的单位来测量。一点...

qq_37422196 ⋅ 01/12 ⋅ 0

杂谈SharpDx中的WIC组件——我们需要WIC的图片编码功能么?

在前文 SharpDX之Direct2D教程II——加载位图文件和保存位图文件 中,发现在VB2010中不能很好的运用SharpDx中的WIC组件进行图片的编码工作。可能是我的设置问题,也可能是SharpDx对VB2010支持...

万仓一黍 ⋅ 2013/10/08 ⋅ 0

Direct2D教程(十二)图层

什么是Layers? Layer,中文译成图层,在Direct2D中可以用来完成一些特殊效果,使用Layer的时候,先将Layer Push到render target,然后进行绘制,此时是直接绘制在Layer上的,绘制完毕后,将...

吞吞吐吐的 ⋅ 2017/10/26 ⋅ 0

关于Direct3D11里汉字显示的一些思考

本系列文章由zhmxy555(毛星云)编写,转载请注明出处。 http://blog.csdn.net/zhmxy555/article/details/8147234 作者:毛星云 邮箱: happylifemxy@163.com 这篇文章里,浅墨希望与大家一起...

长平狐 ⋅ 2012/11/12 ⋅ 0

深度解读 - Windows 7核心图形架构细致分析(转贴)

原帖地址:http://technet.microsoft.com/zh-cn/library/ee921514.aspx 如现在大家所想的那样, Windows7 其实是 Windows Vista 的改进版。 Windows 7 在 Windows Vista 的基础上进行了大量的...

迈克老狼1 ⋅ 2012/12/23 ⋅ 0

WPF 使用 Direct2D1 画图入门

本文来告诉大家如何在 WPF 使用 D2D 画图。 本文是一个系列 WPF 使用 Direct2D1 画图入门 WPF 使用 Direct2D1 画图 绘制基本图形 WPF 使用 SharpDX WPF 使用 SharpDX 在 D3DImage 显示 WPF ...

lindexi_gd ⋅ 05/21 ⋅ 0

WhiteStarUML 5.6.1 发布,UML 建模软件

WhiteStarUML 发布了 5.6.1 版本。 该版本的改动: 新增选项:现在可以在 Windows 7+上面选择启用 Direct2D 来绘制反锯齿图形。勾选 General -> Use Direct2D 添加了“复制/粘贴格式”命令 ...

daxiaoming ⋅ 2015/01/26 ⋅ 9

Direct2D教程(十一)几何变换

什么是几何变换(Transform) 在图形学中,主要有三种几何变换,分别是平移(Translate),旋转(Rotation)和缩放(Scaling)。在D2D中,这三种变换都有实现,而且还有一种不太常见的变换,...

吞吞吐吐的 ⋅ 2017/09/12 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

645. Set Mismatch - LeetCode

Question 645. Set Mismatch Solution 思路: 遍历每个数字,然后将其应该出现的位置上的数字变为其相反数,这样如果我们再变为其相反数之前已经成负数了,说明该数字是重复数,将其将入结果r...

yysue ⋅ 12分钟前 ⋅ 0

Confluence 6 从生产环境中恢复一个测试实例

请参考 Restoring a Test Instance from Production 页面中的内容获得更多完整的说明。 很多 Confluence 的管理员将会使用生产实例运行完整数据和服务的 Confluence 服务器,同时还会设置一个...

honeymose ⋅ 16分钟前 ⋅ 0

Python这么强?红包杀手、消息撤回也可以无视,手机App辅助!

论述 标题也许有点不好理解,其实就是一款利用Python实现的可以监控微信APP内的红包与消息撤回的助手。不得不说,这确实是一款大家钟意的神器。 消息撤回是一件很让人恶心的事,毕竟人都是有...

Python燕大侠 ⋅ 28分钟前 ⋅ 0

压缩打包介绍、gzip压缩工具、bzip2压缩工具、xz压缩工具

压缩打包介绍 压缩的好处不仅能节省磁盘空间而且在传输的时候节省传输时间和网络带宽 windows系统下文件带有 .rar .zip .7z 后缀的就是压缩文件 linux系统下则是 .zip, .gz, .bz2, .xz, ...

黄昏残影 ⋅ 33分钟前 ⋅ 0

观察者模式

1.利用java原生类进行操作 package observer;import java.util.Observable;import java.util.Observer;/** * @author shadow * @Date 2016年8月12日下午7:29:31 * @Fun 观察目标 **/......

Cobbage ⋅ 35分钟前 ⋅ 0

Ubuntu打印服务器配置

参考:https://blog.csdn.net/gsls200808/article/details/50950586 https://blog.csdn.net/jiay2/article/details/80252369 https://wiki.gentoo.org/wiki/HPLIP 由于媳妇儿要大量打印资料,......

大熊猫 ⋅ 41分钟前 ⋅ 0

面试的角度诠释Java工程师(二)

原文出处: locality 续言: 相信每一位简书的作者,都会有我这样的思考:怎么写好一篇文章?或者怎么写好一篇技术类的文章?我就先说说我的感悟吧,写文章其实和写程序是一样的。为什么我会...

颖伙虫 ⋅ 44分钟前 ⋅ 0

github中SSH的Key

https://help.github.com/articles/connecting-to-github-with-ssh/ https://help.github.com/articles/testing-your-ssh-connection/ https://help.github.com/articles/adding-a-new-ssh-k......

whoisliang ⋅ 44分钟前 ⋅ 0

only_full_group_by

我的mysql是在CentOS7.1下面的5.7.17 在 /etc/my.cnf 文件里加上如下: sql_mode='NO_ENGINE_SUBSTITUTION' 然后,重启Mysql服务 systemctl restart mysqld...

SunHacker ⋅ 今天 ⋅ 0

实际项目(SpringBoot项目)中集成Druid

参考网页 https://blog.csdn.net/liuchuanhong1/article/details/55050131 https://blog.csdn.net/CoffeeAndIce/article/details/78707819 https://www.pocketdigi.com/20170530/1577.html 为......

karma123 ⋅ 今天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部