Skip to content

Commit

Permalink
Blank image utility
Browse files Browse the repository at this point in the history
  • Loading branch information
myak555 committed Jan 28, 2018
1 parent 821e4fc commit 4bf5172
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Blank_Image/Blank_Image.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CBAEF0D8-0060-445C-9321-D08F94EE4DD2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Petronode.Blank_Image</RootNamespace>
<AssemblyName>Petronode.BlankImage</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
72 changes: 72 additions & 0 deletions Blank_Image/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

namespace Petronode.Blank_Image
{
class Program
{
static int Main(string[] args)
{
if (args.Length <= 2)
{
Console.WriteLine("Usage: Blank_Image file_name X Y");
Console.WriteLine("Where :");
Console.WriteLine(" X - image Width");
Console.WriteLine(" Y - image Height");
return -1;
}
try
{
int x = Convert.ToInt32(args[1]);
int y = Convert.ToInt32(args[2]);
Bitmap bmp = new Bitmap(x, y);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.White);
g.Dispose();
Save(bmp, args[0]);
bmp.Dispose();
return y;
}
catch (Exception)
{
return -1;
}
}

static void Save(Bitmap bmp, string Destination)
{
FileInfo fi = new FileInfo(Destination);
switch (fi.Extension.ToLower())
{
case ".png":
bmp.Save(Destination, System.Drawing.Imaging.ImageFormat.Png);
break;
case ".tif":
case ".tiff":
bmp.Save(Destination, System.Drawing.Imaging.ImageFormat.Tiff);
break;
case ".jpg":
case ".jpeg":
bmp.Save(Destination, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case ".bmp":
bmp.Save(Destination, System.Drawing.Imaging.ImageFormat.Bmp);
break;
case ".emf":
bmp.Save(Destination, System.Drawing.Imaging.ImageFormat.Emf);
break;
case ".gif":
bmp.Save(Destination, System.Drawing.Imaging.ImageFormat.Gif);
break;
case ".wmf":
bmp.Save(Destination, System.Drawing.Imaging.ImageFormat.Wmf);
break;
default: break;
}
}
}
}
33 changes: 33 additions & 0 deletions Blank_Image/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Petronode.BlankImage")]
[assembly: AssemblyDescription("Cretes a blank image")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Petronode")]
[assembly: AssemblyProduct("Petronode Suite")]
[assembly: AssemblyCopyright("Copyright © Mike Yakimov 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b59e294c-69f9-410f-8215-8be02862cb4f")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit 4bf5172

Please sign in to comment.