Permalink
Browse files

Implement DrawImage methods part 1.

  • Loading branch information...
kjpou1 committed Aug 29, 2013
1 parent e573e31 commit 22fbaf05eaa8773734d3724cdbff09c6305aaee5
@@ -0,0 +1,30 @@
+using System;
+using System.Drawing;
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+using MonoMac.ObjCRuntime;
+
+namespace DrawImageTests
+{
+ public partial class AppDelegate : NSApplicationDelegate
+ {
+ MainWindowController mainWindowController;
+
+ public AppDelegate ()
+ {
+ }
+
+ public override void FinishedLaunching (NSObject notification)
+ {
+ mainWindowController = new MainWindowController ();
+ mainWindowController.Window.MakeKeyAndOrderFront (this);
+ mainWindowController.Window.ContentView.AddSubview(new DrawingView(mainWindowController.Window.ContentView.Bounds));
+ }
+
+ public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
+ {
+ return true;
+ }
+ }
+}
+

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{1C81B532-1642-45E6-860A-A8F3817734E7}</ProjectGuid>
+ <ProjectTypeGuids>{948B3504-5B70-4649-8FE4-BDE1FB46EC69};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>DrawImageTests</RootNamespace>
+ <MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
+ <AssemblyName>DrawImageTests</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ <UseSGen>false</UseSGen>
+ <IncludeMonoRuntime>false</IncludeMonoRuntime>
+ <EnablePackageSigning>false</EnablePackageSigning>
+ <CodeSigningKey>Mac Developer</CodeSigningKey>
+ <EnableCodeSigning>false</EnableCodeSigning>
+ <CreatePackage>false</CreatePackage>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ <LinkMode>Full</LinkMode>
+ <UseSGen>false</UseSGen>
+ <IncludeMonoRuntime>true</IncludeMonoRuntime>
+ <EnablePackageSigning>false</EnablePackageSigning>
+ <CodeSigningKey>Developer ID Application</CodeSigningKey>
+ <EnableCodeSigning>true</EnableCodeSigning>
+ <CreatePackage>true</CreatePackage>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhoneSimulator' ">
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\iPhoneSimulator\AppStore</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ <LinkMode>Full</LinkMode>
+ <UseSGen>false</UseSGen>
+ <IncludeMonoRuntime>true</IncludeMonoRuntime>
+ <PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
+ <CreatePackage>true</CreatePackage>
+ <CodeSigningKey>3rd Party Mac Developer Application</CodeSigningKey>
+ <EnableCodeSigning>true</EnableCodeSigning>
+ <EnablePackageSigning>true</EnablePackageSigning>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="MonoMac">
+ <HintPath>..\..\..\..\monomac\src\MonoMac.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Resources\" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="MainWindow.cs" />
+ <Compile Include="MainWindowController.cs" />
+ <Compile Include="MainWindow.designer.cs">
+ <DependentUpon>MainWindow.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Main.cs" />
+ <Compile Include="AppDelegate.cs" />
+ <Compile Include="AppDelegate.designer.cs">
+ <DependentUpon>AppDelegate.cs</DependentUpon>
+ </Compile>
+ <Compile Include="DrawingView.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <InterfaceDefinition Include="MainWindow.xib" />
+ <InterfaceDefinition Include="MainMenu.xib" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Info.plist" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\sysdrawing-coregraphics-Mac\sysdrawing-coregraphics-Mac.csproj">
+ <Project>{C675FE3F-497D-4CE7-B441-3C0299B30C10}</Project>
+ <Name>sysdrawing-coregraphics-Mac</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="bitmap25.png" />
+ <Content Include="bitmap50.png" />
+ </ItemGroup>
+</Project>
@@ -0,0 +1,90 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+
+namespace DrawImageTests
+{
+ public partial class DrawingView : MonoMac.AppKit.NSView
+ {
+
+ #region Constructors
+
+ // Called when created from unmanaged code
+ public DrawingView (IntPtr handle) : base (handle)
+ {
+ Initialize ();
+ }
+
+ // Called when created directly from a XIB file
+ [Export ("initWithCoder:")]
+ public DrawingView (NSCoder coder) : base (coder)
+ {
+ Initialize ();
+ }
+
+ // Shared initialization code
+ void Initialize ()
+ {
+ this.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
+ }
+
+ public DrawingView (RectangleF rect) : base (rect)
+ {
+ Initialize();
+ }
+
+#endregion
+
+ Font Font = new System.Drawing.Font("Helvetica",12);
+
+ Image bmp;
+ Image bmp2;
+
+ Rectangle src = new Rectangle(0, 0, 50, 50);
+ RectangleF srcF = new Rectangle(0, 0, 50, 50);
+ Rectangle dst = new Rectangle(170, 170, 100, 100);
+ RectangleF dstF = new Rectangle(270, 270, 100, 100);
+
+ public override void DrawRect (System.Drawing.RectangleF dirtyRect)
+ {
+ Graphics g = new Graphics();
+ g.InterpolationMode = InterpolationMode.NearestNeighbor;
+
+ g.Clear(Color.Wheat);
+
+ var mainBundle = NSBundle.MainBundle;
+ var filePath = mainBundle.PathForResource("bitmap25","png");
+
+ var bmp = Image.FromFile(filePath);
+
+ filePath = mainBundle.PathForResource("bitmap50","png");
+
+ var bmp2 = Image.FromFile(filePath);
+
+
+ //g.DrawImage(bmp, new Point[]{new Point(170,10), new Point(250,0), new Point(100,100)}, src, GraphicsUnit.Pixel );
+ //g.DrawImage(bmp, new PointF[]{new PointF(70,10), new PointF(150,0), new PointF(10,100)}, srcF, GraphicsUnit.Pixel );
+ // Create parallelogram for drawing image.
+ Point ulCorner = new Point(110, 100);
+ Point urCorner = new Point(350, 100);
+ Point llCorner = new Point(100, 200);
+ Point[] destPara = {ulCorner, urCorner, llCorner};
+
+ g.DrawImage(bmp2, destPara);
+
+ //g.DrawImage (bmp, dst);
+
+
+ g.Dispose();
+
+ }
+ }
+}
+
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleName</key>
+ <string>DrawImageTests</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.6</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
@@ -0,0 +1,18 @@
+using System;
+using System.Drawing;
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+using MonoMac.ObjCRuntime;
+
+namespace DrawImageTests
+{
+ class MainClass
+ {
+ static void Main (string[] args)
+ {
+ NSApplication.Init ();
+ NSApplication.Main (args);
+ }
+ }
+}
+
Oops, something went wrong.

0 comments on commit 22fbaf0

Please sign in to comment.