Skip to content

Commit e0cff96

Browse files
committed
support for 32bit input images
1 parent 2b563ba commit e0cff96

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

ColorRegionMaskCreator/ImageMasks.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ private static void CreateFiles(string baseImageFilePath, string colorMaskFile,
156156
// foreground extends to these coordinates (can be used for cropping)
157157
var foregroundRect = new ForegroundRectangle();
158158

159+
var channelsInputBg = bmpBackgroundJpg.PixelFormat == PixelFormat.Format32bppArgb ? 4 : 3;
160+
var channelsInputMask = bmpColorMask?.PixelFormat == PixelFormat.Format32bppArgb ? 4 : 3;
161+
159162
unsafe
160163
{
161164
byte* scan0Jpg = (byte*)bmpDataJpg.Scan0.ToPointer();
@@ -168,9 +171,9 @@ private static void CreateFiles(string baseImageFilePath, string colorMaskFile,
168171
{
169172
for (int j = 0; j < height; j++)
170173
{
171-
byte* dJpg = scan0Jpg + j * bmpDataJpg.Stride + i * 3;
174+
byte* dJpg = scan0Jpg + j * bmpDataJpg.Stride + i * channelsInputBg;
172175
byte* dBg = scan0Background + j * bmpDataBackground.Stride + i * 4;
173-
byte* dCm = scan0ColorMask != null ? (scan0ColorMask + j * bmpDataColorMask.Stride + i * 3) : null;
176+
byte* dCm = scan0ColorMask != null ? (scan0ColorMask + j * bmpDataColorMask.Stride + i * channelsInputMask) : null;
174177

175178
if (dJpg[1] >= _config.GreenScreenMinGreen
176179
&& dJpg[2] * _config.GreenScreenFactorGLargerThanRB <= dJpg[1]

ColorRegionMaskCreator/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
2-
using System.CodeDom;
32
using System.Collections.Generic;
43
using System.Diagnostics;
54
using System.IO;
5+
using System.Reflection;
66

77
namespace ColorRegionMaskCreator
88
{
@@ -54,7 +54,10 @@ static void Main(string[] args)
5454
}
5555
}
5656

57+
var fileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
58+
5759
Console.WriteLine();
60+
Console.WriteLine($"Color region mask creator, version {fileVersionInfo.FileVersion}");
5861
Console.WriteLine("Creates base images and according mask images from jpg or png files in the in folder.");
5962
Console.WriteLine("The base image can have a green screen which will be made transparent in the output.");
6063
Console.WriteLine("The mask file is expected to have regions that are r, g, b, gb, rg, rb; the contrast will be maximized.");
@@ -87,9 +90,9 @@ static void Main(string[] args)
8790
var answer = Console.ReadLine();
8891
dontCreateRegionHighlights = answer?.Trim().ToLowerInvariant() != "y";
8992
}
90-
93+
9194
Console.WriteLine();
92-
95+
9396
var autoStart = argDict.ContainsKey("autostart");
9497
if (!autoStart)
9598
{

ColorRegionMaskCreator/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("ColorRegionMaskCreator")]
13-
[assembly: AssemblyCopyright("Copyright © 2022 by cadon")]
13+
[assembly: AssemblyCopyright("Copyright © 2025 by cadon")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.2.0")]
36+
[assembly: AssemblyFileVersion("1.0.3.0")]

0 commit comments

Comments
 (0)