So… I have grayscale base64 data for alpha.
I need to make 2 sets of dotnet image for dotnet button.
Basically I need white color and black color image with same alpha.
Any idea?
So… I have grayscale base64 data for alpha.
I need to make 2 sets of dotnet image for dotnet button.
Basically I need white color and black color image with same alpha.
Any idea?
you need create a new bitmap with C#, such as
Bitmap bmp = new Bitmap(img);
Bitmap abmp = new Bitmap(aimg);
for (int i = 0; i < bmp.Width; i++)
{
for (int j = 0; j < bmp.Height; j++)
{
Color bmpcolor = bmp.GetPixel(i, j);
Color abmpcolor = abmp.GetPixel(i, j);
int a = abmpcolor.A;
int r = bmpcolor.R;
int g = bmpcolor.G;
int b = bmpcolor.B;
byte A = (byte)a;
byte R = (byte)r;
byte G = (byte)g;
byte B = (byte)b;
bmpcolor = Color.FromArgb(A, R, G, B);
bmp.SetPixel(i, j, bmpcolor);
}
}
return bmp;
Thanks!
I guess that.
How can I do with just dotnet and maxscript?
Something like…
I found this thread…
I think this is what I want… it is till c#
//get a graphics object from the image so we can draw on it
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(finalImage))
{
//set background color
g.Clear(System.Drawing.Color.Black);
//go through each image and draw it on the final image
int offset = 0;
foreach (System.Drawing.Bitmap image in images)
{
g.DrawImage(image,
new System.Drawing.Rectangle(offset, 0, image.Width, image.Height));
offset += image.Width;
}
}
definition
fn createdotnetimage =
(
source = "
using System.Drawing;
public class getopimage
{
static void Main()
{
}
public Image myimage;
public getopimage(Bitmap m, int r, int g, int b)
{
Image img = m;
Bitmap bmp = new Bitmap(img);
for (int i = 0; i < bmp.Width; i++)
{
for (int j = 0; j < bmp.Height; j++)
{
Color bmpcolor = bmp.GetPixel(i, j);
int a = bmpcolor.A;
byte A = (byte)a;
byte R = (byte)r;
byte G = (byte)g;
byte B = (byte)b;
bmpcolor = Color.FromArgb(A, R, G, B);
bmp.SetPixel(i, j, bmpcolor);
}
}
myimage =bmp;
}
}"
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.ReferencedAssemblies.Add("System.Drawing.dll")
CompilerParams.GenerateExecutable = true
CompilerParams.GenerateInMemory = true
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
compilerResults.CompiledAssembly
)
createdotnetimage ()
usage
image = imagepath
rgbcolor=#(255,255,255) --rgb color
yourcontrols.image = ((DotNetClass "System.Activator").CreateInstance (DotNetClass "getopimage") #((dotnetclass "System.Drawing.Image").FromFile image,rgbcolor[1],rgbcolor[2],rgbcolor[3])).myimage
--(dotnetclass "System.Drawing.Image").FromFile image can change to the base64 image