-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Windows.Forms; | ||
using Cairo; | ||
using Color = Cairo.Color; | ||
using Graphics = System.Drawing.Graphics; | ||
|
||
namespace DrawPngInMemory | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
public Graphics Graphics1 { get; private set; } | ||
public Context Context1 { get; set; } | ||
public Win32Surface Surface1 { get; private set; } | ||
byte[] pngData = System.IO.File.ReadAllBytes("1.png"); | ||
|
||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override void OnPaint(PaintEventArgs e) | ||
{ | ||
base.OnPaint(e); | ||
|
||
Graphics1 = e.Graphics; | ||
Surface1 = new Win32Surface(Graphics1.GetHdc()); | ||
Context1 = new Context(Surface1); | ||
|
||
using (ImageSurface pngImageSurface = new ImageSurface(pngData)) | ||
{ | ||
Context1.SetSource(pngImageSurface); | ||
Context1.Paint(); | ||
} | ||
|
||
Graphics1.Dispose(); | ||
Context1.Dispose(); | ||
Surface1.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace DrawPngInMemory | ||
{ | ||
static class Program | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
Application.EnableVisualStyles(); | ||
Application.SetCompatibleTextRenderingDefault(false); | ||
Application.Run(new Form1()); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace WinFormDemo | ||
{ | ||
static class Program | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
Application.EnableVisualStyles(); | ||
Application.SetCompatibleTextRenderingDefault(false); | ||
Application.Run(new Form1()); | ||
} | ||
} | ||
} |