[Managed C#] masking using a paletted mask-map
Moderator: MaxCoderz Staff
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
You're not going to believe how I "solved" it.
Apparently you have to substact the row number, the images are the exact same size, maybe they marshal.copy is uhm.. bad?
But it only solves the problem for the problem-pictures, the good ones are messed up in same way now (so I'll have to figure out a way to determine whether a picture is good or not)
And there are those that need 2 or 3 times the row-number substracted.
But I guess this narrows down the problem to uhm.. well to what? It defenitly has something to do with not-matching widths.. Even if the pictures have the same size..
Code: Select all
if (SourceMaskArray[i] >= index) SourceImageArray[i-(int)(i/Width)] = 0;
But it only solves the problem for the problem-pictures, the good ones are messed up in same way now (so I'll have to figure out a way to determine whether a picture is good or not)
And there are those that need 2 or 3 times the row-number substracted.
But I guess this narrows down the problem to uhm.. well to what? It defenitly has something to do with not-matching widths.. Even if the pictures have the same size..
Last edited by King Harold on Wed 01 Nov, 2006 8:18 pm, edited 1 time in total.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Oh dear.
Take a look at the width of the images that do work, then the width of those that don't.
The ones that do are multiples of 8 pixels wide, so are multiples of 8 bytes wide. The stride (width in bytes) of these images are always multiples of 8 bytes.
I've not thought of this as the images I usually deal with are 32bpp and even widths (and as each pixel is 4 bytes, I just have to make them even widths to let the stride "fit").
I've uploaded a fixed project that works, taking the stride of the image into consideration.
The palette order is still rather weird... I'm hoping there's some reference somewhere as to which order the palette should really be.
Take a look at the width of the images that do work, then the width of those that don't.
The ones that do are multiples of 8 pixels wide, so are multiples of 8 bytes wide. The stride (width in bytes) of these images are always multiples of 8 bytes.
I've not thought of this as the images I usually deal with are 32bpp and even widths (and as each pixel is 4 bytes, I just have to make them even widths to let the stride "fit").
I've uploaded a fixed project that works, taking the stride of the image into consideration.
The palette order is still rather weird... I'm hoping there's some reference somewhere as to which order the palette should really be.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Lucky guess again, really. I just noticed that the ones that worked were multiples of eight wide, then remembered about the stride. A bit of debugging showed that no, the stride was different to the width for a few of the images.
Do you have any sort of image that lists the colours in the "correct" order? I can't really see any obvious pattern to which is the first and which is the last colour to fill.
Do you have any sort of image that lists the colours in the "correct" order? I can't really see any obvious pattern to which is the first and which is the last colour to fill.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am