* Client.Self.Position now does acceleration/velocity interpolation

* Added LLVector3 * float operator
* Adding Oven.cs to Baker (will be moved in to libsecondlife later) that does the first baby steps of baking
* Added the missing Helpers.GetResourceStream() function
* Changed readonly Settings values to const


git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1110 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2007-04-09 08:03:12 +00:00
parent 3c81807d8b
commit f44c012f60
14 changed files with 176 additions and 23 deletions

View File

@@ -41,6 +41,7 @@
<DependentUpon>frmBaker.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Oven.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Baker.cs" />
@@ -67,4 +68,4 @@
<Name>libsecondlife</Name>
</ProjectReference>
</ItemGroup>
</Project>
</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

@@ -47,6 +47,7 @@ namespace Baker
this.pic1.Size = new System.Drawing.Size(256, 256);
this.pic1.TabIndex = 0;
this.pic1.TabStop = false;
this.pic1.AutoSize = true;
//
// cmdLoadPic1
//
@@ -66,6 +67,7 @@ namespace Baker
this.pic2.Size = new System.Drawing.Size(256, 256);
this.pic2.TabIndex = 2;
this.pic2.TabStop = false;
this.pic1.AutoSize = true;
//
// pic3
//
@@ -75,6 +77,7 @@ namespace Baker
this.pic3.Size = new System.Drawing.Size(256, 256);
this.pic3.TabIndex = 3;
this.pic3.TabStop = false;
this.pic1.AutoSize = true;
//
// cmdLoadPic2
//
@@ -130,3 +133,4 @@ namespace Baker
}
}

View File

@@ -23,7 +23,8 @@ namespace Baker
if (stream != null)
{
pic1.Image = OpenJPEGNet.LoadTGAClass.LoadTGA(stream);
Bitmap alphaMask = OpenJPEGNet.LoadTGAClass.LoadTGA(stream);
pic1.Image = Oven.ModifyAlphaMask(alphaMask, 245, 0.0f);
}
else
{