Thanks Ben.
I tried that, now it compiled file. But the memory address of the
original image and the one I receive inside ChangeImage(..) is still
different. Is there a rul for calling this method too?
I call it like this:
// In a form's scope
Bitmap ^m_Bitmap;
ManagedImageModifier<MyModifier> modifier;
bool result = modifier.ChangeImage(m_Bitmap);
> > Problem#2:
> > Anyways, I chose to classify this parameter as a reference variable,
[quoted text clipped - 32 lines]
>
> - Show quoted text -
Ben Voigt [C++ MVP] - 21 Apr 2008 17:26 GMT
> Thanks Ben.
>
> I tried that, now it compiled file. But the memory address of the
> original image and the one I receive inside ChangeImage(..) is still
> different. Is there a rul for calling this method too?
It's a garbage collected object, so it can move around in memory. That's
why ^ and % ("tracking" pointer and reference) instead of * and &.
Can you verify whether the function was able to change the caller's copy of
the variable?
> I call it like this:
>
[quoted text clipped - 42 lines]
>>
>> - Show quoted text -
Ben Voigt [C++ MVP] - 21 Apr 2008 18:43 GMT
> Thanks Ben.
>
[quoted text clipped - 10 lines]
>
> bool result = modifier.ChangeImage(m_Bitmap);
Does it still misbehave when simplified?
Try this:
Bitmap ^m_Bitmap;
m_Bitmap = gcnew Bitmap(64, 64);
::System::Diagnostics::Trace::WriteLine("m_Bitmap " + ((m_Bitmap ==
nullptr)? "is": "is not") + " NULL");
ChangeImage(m_Bitmap);
::System::Diagnostics::Trace::WriteLine("m_Bitmap " + ((m_Bitmap ==
nullptr)? "is": "is not") + " NULL");
bool ChangeImage(Bitmap^% bmp) { bmp = nullptr; return true; }
Then move ChangeImage into your template class as a static method, call it
there, test again.
Then make ChangeImage an instance method, test again.
Then start adding the ChangeImage logic.
I suspect that ChangeImage didn't reach the line which reassigned the
parameter to a new value. It is declared with a return value but you aren't
checking it.
Pixel.to.life - 22 Apr 2008 05:44 GMT
> > Thanks Ben.
>
[quoted text clipped - 36 lines]
>
> - Show quoted text -
Ben,
That worked like a charm.
Thanks a ton. I was stuck on this for almost a day!!!
Hope I can be of some use to you too someday:-)
Ben Voigt [C++ MVP] - 22 Apr 2008 14:33 GMT
> Ben,
>
[quoted text clipped - 3 lines]
>
> Hope I can be of some use to you too someday:-)
You're welcome.