File tree Expand file tree Collapse file tree 4 files changed +130
-0
lines changed
Expand file tree Collapse file tree 4 files changed +130
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . Windows . Forms ;
2+ using Cairo ;
3+ using Color = Cairo . Color ;
4+ using Graphics = System . Drawing . Graphics ;
5+
6+ namespace DrawPngInMemory
7+ {
8+ public partial class Form1 : Form
9+ {
10+ public Graphics Graphics1 { get ; private set ; }
11+ public Context Context1 { get ; set ; }
12+ public Win32Surface Surface1 { get ; private set ; }
13+ byte [ ] pngData = System . IO . File . ReadAllBytes ( "1.png" ) ;
14+
15+ public Form1 ( )
16+ {
17+ InitializeComponent ( ) ;
18+ }
19+
20+ protected override void OnPaint ( PaintEventArgs e )
21+ {
22+ base . OnPaint ( e ) ;
23+
24+ Graphics1 = e . Graphics ;
25+ Surface1 = new Win32Surface ( Graphics1 . GetHdc ( ) ) ;
26+ Context1 = new Context ( Surface1 ) ;
27+
28+ using ( ImageSurface pngImageSurface = new ImageSurface ( pngData ) )
29+ {
30+ Context1 . SetSource ( pngImageSurface ) ;
31+ Context1 . Paint ( ) ;
32+ }
33+
34+ Graphics1 . Dispose ( ) ;
35+ Context1 . Dispose ( ) ;
36+ Surface1 . Dispose ( ) ;
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Threading . Tasks ;
4+ using System . Windows . Forms ;
5+
6+ namespace DrawPngInMemory
7+ {
8+ static class Program
9+ {
10+ /// <summary>
11+ /// The main entry point for the application.
12+ /// </summary>
13+ [ STAThread ]
14+ static void Main ( )
15+ {
16+ Application . EnableVisualStyles ( ) ;
17+ Application . SetCompatibleTextRenderingDefault ( false ) ;
18+ Application . Run ( new Form1 ( ) ) ;
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Threading . Tasks ;
4+ using System . Windows . Forms ;
5+
6+ namespace WinFormDemo
7+ {
8+ static class Program
9+ {
10+ /// <summary>
11+ /// The main entry point for the application.
12+ /// </summary>
13+ [ STAThread ]
14+ static void Main ( )
15+ {
16+ Application . EnableVisualStyles ( ) ;
17+ Application . SetCompatibleTextRenderingDefault ( false ) ;
18+ Application . Run ( new Form1 ( ) ) ;
19+ }
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments