Moving examples, mapgenerator, and VisualParamGenerator to Programs folder (SVN is seriously ruined still, don't check out yet)

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1961 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2008-07-22 23:21:49 +00:00
parent ef71c02528
commit f2dde3daae
153 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Baker
{
static class Baker
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmBaker());
}
}
}

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<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>{4A32A4E5-717C-4B60-B3D7-704518684893}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Baker</RootNamespace>
<AssemblyName>Baker</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\bin\</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>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-docs|AnyCPU' ">
<OutputPath>bin\Release-docs\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<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>
-->
<ItemGroup>
<EmbeddedResource Include="frmBaker.resx">
<DependentUpon>frmBaker.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Oven.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Baker.cs" />
<Compile Include="frmBaker.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmBaker.designer.cs">
<DependentUpon>frmBaker.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenMetaverse.csproj">
<Project>{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}</Project>
<Name>OpenMetaverse</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,69 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace Baker
{
public static class Oven
{
public static Bitmap ModifyAlphaMask(Bitmap alpha, byte weight, float ramp)
{
// Create the new modifiable image (our canvas)
int width = alpha.Width;
int height = alpha.Height;
int pixelFormatSize = Image.GetPixelFormatSize(alpha.PixelFormat) / 8;
int stride = width * pixelFormatSize;
byte[] data = new byte[stride * height];
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0);
Bitmap modified = new Bitmap(width, height, stride, alpha.PixelFormat, pointer);
// Copy the existing alpha mask to the canvas
Graphics g = Graphics.FromImage(modified);
g.DrawImageUnscaledAndClipped(alpha, new Rectangle(0, 0, width, height));
g.Dispose();
// Modify the canvas based on the input weight and ramp values
// TODO: use the ramp
// TODO: only bother with the alpha values
for (int i = 0; i < data.Length; i++)
{
if (data[i] < weight) data[i] = 0;
}
return modified;
}
public static Bitmap ApplyAlphaMask(Bitmap source, Bitmap alpha)
{
// Create the new modifiable image (our canvas)
int width = source.Width;
int height = source.Height;
if (alpha.Width != width || alpha.Height != height ||
alpha.PixelFormat != source.PixelFormat)
{
throw new Exception("Source image and alpha mask formats do not match");
}
int pixelFormatSize = Image.GetPixelFormatSize(source.PixelFormat) / 8;
int stride = width * pixelFormatSize;
byte[] data = new byte[stride * height];
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0);
Bitmap modified = new Bitmap(width, height, stride, source.PixelFormat, pointer);
// Copy the source image to the canvas
Graphics g = Graphics.FromImage(modified);
g.DrawImageUnscaledAndClipped(source, new Rectangle(0, 0, width, height));
g.Dispose();
// Get access to the pixel data for the alpha mask (probably using lockbits)
// Combine the alpha mask alpha bytes in to the canvas
return modified;
}
}
}

View File

@@ -0,0 +1,134 @@
namespace Baker
{
partial class frmBaker
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pic1 = new System.Windows.Forms.PictureBox();
this.cmdLoadShirt = new System.Windows.Forms.Button();
this.scrollWeight = new System.Windows.Forms.HScrollBar();
this.cmdLoadSkin = new System.Windows.Forms.Button();
this.cboMask = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.pic1)).BeginInit();
this.SuspendLayout();
//
// pic1
//
this.pic1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pic1.Location = new System.Drawing.Point(12, 41);
this.pic1.Name = "pic1";
this.pic1.Size = new System.Drawing.Size(512, 483);
this.pic1.TabIndex = 0;
this.pic1.TabStop = false;
//
// cmdLoadShirt
//
this.cmdLoadShirt.Location = new System.Drawing.Point(449, 530);
this.cmdLoadShirt.Name = "cmdLoadShirt";
this.cmdLoadShirt.Size = new System.Drawing.Size(75, 23);
this.cmdLoadShirt.TabIndex = 1;
this.cmdLoadShirt.Text = "Load Shirt";
this.cmdLoadShirt.UseVisualStyleBackColor = true;
//
// scrollWeight
//
this.scrollWeight.Location = new System.Drawing.Point(12, 530);
this.scrollWeight.Maximum = 255;
this.scrollWeight.Name = "scrollWeight";
this.scrollWeight.Size = new System.Drawing.Size(345, 23);
this.scrollWeight.TabIndex = 0;
this.scrollWeight.Scroll += new System.Windows.Forms.ScrollEventHandler(this.scrollWeight_Scroll);
//
// cmdLoadSkin
//
this.cmdLoadSkin.Location = new System.Drawing.Point(366, 530);
this.cmdLoadSkin.Name = "cmdLoadSkin";
this.cmdLoadSkin.Size = new System.Drawing.Size(75, 23);
this.cmdLoadSkin.TabIndex = 2;
this.cmdLoadSkin.Text = "Load Skin";
this.cmdLoadSkin.UseVisualStyleBackColor = true;
this.cmdLoadSkin.Click += new System.EventHandler(this.cmdLoadSkin_Click);
//
// cboMask
//
this.cboMask.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboMask.FormattingEnabled = true;
this.cboMask.Items.AddRange(new object[] {
"glove_length_alpha",
"gloves_fingers_alpha",
"jacket_length_lower_alpha",
"jacket_length_upper_alpha",
"jacket_open_lower_alpha",
"jacket_open_upper_alpha",
"pants_length_alpha",
"pants_waist_alpha",
"shirt_bottom_alpha",
"shirt_collar_alpha",
"shirt_collar_back_alpha",
"shirt_sleeve_alpha",
"shoe_height_alpha",
"skirt_length_alpha",
"skirt_slit_front_alpha",
"skirt_slit_left_alpha",
"skirt_slit_right_alpha"});
this.cboMask.Location = new System.Drawing.Point(358, 12);
this.cboMask.Name = "cboMask";
this.cboMask.Size = new System.Drawing.Size(166, 21);
this.cboMask.TabIndex = 3;
this.cboMask.SelectedIndexChanged += new System.EventHandler(this.cboMask_SelectedIndexChanged);
//
// frmBaker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(538, 563);
this.Controls.Add(this.cboMask);
this.Controls.Add(this.cmdLoadSkin);
this.Controls.Add(this.scrollWeight);
this.Controls.Add(this.cmdLoadShirt);
this.Controls.Add(this.pic1);
this.Name = "frmBaker";
this.Text = "Baker";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmBaker_FormClosing);
this.Load += new System.EventHandler(this.frmBaker_Load);
((System.ComponentModel.ISupportInitialize)(this.pic1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pic1;
private System.Windows.Forms.HScrollBar scrollWeight;
private System.Windows.Forms.Button cmdLoadShirt;
private System.Windows.Forms.Button cmdLoadSkin;
private System.Windows.Forms.ComboBox cboMask;
}
}

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
using System.Windows.Forms;
using System.IO;
using OpenMetaverse.Imaging;
namespace Baker
{
public partial class frmBaker : Form
{
Bitmap AlphaMask;
public frmBaker()
{
InitializeComponent();
}
private void frmBaker_Load(object sender, EventArgs e)
{
cboMask.SelectedIndex = 0;
DisplayResource(cboMask.Text);
}
private void DisplayResource(string resource)
{
Stream stream = OpenMetaverse.Helpers.GetResourceStream(resource + ".tga");
if (stream != null)
{
AlphaMask = LoadTGAClass.LoadTGA(stream);
stream.Close();
ManagedImage managedImage = new ManagedImage(AlphaMask);
// FIXME: Operate on ManagedImage instead of Bitmap
pic1.Image = Oven.ModifyAlphaMask(AlphaMask, (byte)scrollWeight.Value, 0.0f);
}
else
{
MessageBox.Show("Failed to load embedded resource \"" + resource + "\"", "Baker",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void scrollWeight_Scroll(object sender, ScrollEventArgs e)
{
pic1.Image = Oven.ModifyAlphaMask(AlphaMask, (byte)scrollWeight.Value, 0.0f);
}
private void frmBaker_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void cmdLoadSkin_Click(object sender, EventArgs e)
{
}
private void cmdLoadShirt_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
//dialog.Filter = "JPEG2000 (*.jp2,*.j2c,*.j2k)|";
//if (dialog.ShowDialog() == DialogResult.OK)
//{
// try
// {
// byte[] j2kdata = File.ReadAllBytes(dialog.FileName);
// Image image = OpenJPEGNet.OpenJPEG.DecodeToImage(j2kdata);
// pic1.Image = image;
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.Message);
// }
//}
}
private void cboMask_SelectedIndexChanged(object sender, EventArgs e)
{
DisplayResource(cboMask.Text);
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>