Re: analysing a bitmap



"Dodgy" <Dodgy@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ci499112otv5u9rqgbpdl4bs3886nljp3r@xxxxxxxxxx
> On Wed, 25 May 2005 16:35:48 +0200, "Peter Bauer"
> <PeterBauer@xxxxxxxx> waffled on about something:

>>> Then it exploded because you defined myimagemap as a 1 based array,
>>> not 0 based one.
>>
>> i overwrite the array with:
>>
>> for y:= 0 to TempBitmap.Height-1 do
>> begin
>> P:= TempBitmap.ScanLine[y];
>> for x:= 0 to TempBitmap.Width-1 do
>> begin
>> if (P^.rgbRed = 0) and (P^.rgbGreen = 0) and (P^.rgbBlue = 0)
>> then
>> MyImageMap[X, Y]:= 1
>> else
>> MyImageMap[X, Y]:= 0;
>> end;
>> end;

I wrote the sample code. It was an essential feature that the image
array was one-based; otherwise the checks for stopping at the
border would have to be different. But bitmaps are zero-based so
you really have to offset the image array when copying between it
and the bitmap. You can also offset the bitmap coordinates but one
of them has to give.


[...]
> Your loop starts with x and y at zero, which means the first time you
> try to set a pixel in MyImageMap you are setting MyImageMap[0,0] which
> is outside the array, which on my D5 makes it go pop.

Peter, at this point you enable range checking. And overflow checking,
and that third option in that little group that I can't think of right
now. And don't turn them off again. Anywhere. Ever.

Just to be on the paranoid side, do you have short-circuit Boolean
evaluation enabled?


>>> You appear to be getting stuck in a loop... As your fill routine is
>>> self calling this eventually (i.e. a fraction of a second later)
>>> blows the stack limit.
>>>
>>> I think this occurs when old colour=colour, although I haven't quite
>>> got my head round your fill logic.
>>
>> thats right, now i'm skipping this with
>> if OldColour=Colour then exit;
>
> That would help. :-)

That should not be necessary. The fill logic is "(1) paint the new colour
at the current coordinate; (2) for all four directions, check if the fill
should continue and if it should, let it."

I haven't had the time to try and duplicate the result of oscillating
between Y=0 and Y=1. (Y should never reach 0 to begin with, it violates
the condition "Low(Y)<Y".) I'll look at it tonight.

Peter, what image are you using to test with? Does it generate a "mask"
of a blob of zeroes in the middle with ones for black all around the
border? If so, the fill should not even reach the border based on the
colour data.

Something odd is happening here.

Groetjes,
Maarten Wiltink


.



Relevant Pages

  • Re: analysing a bitmap
    ... > Then it exploded because you defined myimagemap as a 1 based array, ... > the stack limit. ... > dumping coordinates to a memo1 box so you can see where it's going, ...
    (comp.lang.pascal.delphi.misc)
  • Re: analysing a bitmap
    ... >> Then it exploded because you defined myimagemap as a 1 based array, ... TCoordinateX = 1..242; ... Your loop starts with x and y at zero, which means the first time you ...
    (comp.lang.pascal.delphi.misc)
  • Re: Scale a vector
    ... I need to resize a one-dimensional array. ... is greater than the width of the original bitmap. ... The array lenght must be the same, so I've to scale RGB proj. ... the value of the middle pixel, I think the solution is basically the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Speed of C# and GDI+
    ... .NET CF compiler generates MSIL code which is a CPU independent ... However the Bitmap ... class provides a constructor which takes a stream parameter. ... with this array as the parameter. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Speed of C# and GDI+
    ... .NET CF compiler generates MSIL code which is a CPU independent ... However the Bitmap ... class provides a constructor which takes a stream parameter. ... with this array as the parameter. ...
    (microsoft.public.pocketpc.developer)