SPQR_ROME

// I have performed Bitmap Clone that seems to be ok (saved both the sorce and the clone to a file to verify).

// The problem is that when I perform

BitmapClon->LockBits(&rect,ImageLockModeRead |ImageLockModeWrite,

PixelFormat24bppRGB,&bmDataClon);

// I don't seems to get the BitmapData. When I do

strideClon = bmDataClon.Stride;

// I get a value of 0 . Any suggestion of what might have I doing wrong

// Thank you



Re: Visual C++ Express Edition Bitmap Clone problem

nobugz






Re: Visual C++ Express Edition Bitmap Clone problem

SPQR_ROME

Since I had

Bitmap* BitmapSrc;

Bitmap* BitmapClon;

I tryed the following

BitmapClon = new Bitmap(*BitmapSrc);

but now I get the following while trying to build it

1>..\Pixelembed V1_6.cpp(349) : error C2248: 'Gdiplus::Bitmap::Bitmap' : cannot access private member declared in class 'Gdiplus::Bitmap'

1> c:\program files\microsoft sdks\windows\v6.0\include\GdiplusHeaders.h(630) : see declaration of 'Gdiplus::Bitmap::Bitmap'

1> c:\program files\microsoft sdks\windows\v6.0\include\GdiplusHeaders.h(494) : see declaration of 'Gdiplus::Bitmap'





Re: Visual C++ Express Edition Bitmap Clone problem

nobugz

What are the odds of you switching to the managed C++/CLI syntax, it would make this a heckofalot easier. The native GDI+ Bitmap class doesn't have a constructor to take a *Bitmap. You'd have to do something like this:

Bitmap* BitmapClon = new Bitmap(BitmapSrc->GetWidth() , BitmapSrc->GetHeight(), PixelFormat32bppARGB);
Graphics* gr = Graphics::FromImage(BitmapClon);
gr->DrawImage(BitmapSrc, 0, 0);






Re: Visual C++ Express Edition Bitmap Clone problem

SPQR_ROME

I need to manipulate the Bitmap, so it seems that your suggestion wouldn't solve my problem.

I'm already compiling with /CLI but apparently I do not do it properly as I'm a newbie.

I would like to switch to the managed C++/CLI syntax and appreciate if you could show me how or give a refference that I could use.

I have tryed to define "Bitmap^ BitmapClon" but failed (the compiler switched it to '*').

Thank you





Re: Visual C++ Express Edition Bitmap Clone problem

nobugz

You can manipulate BitmapClon as needed, the code snippet just ensures it is properly initialized. Put

#using namespace System::Drawing

at the top of your source code file to use the managed Bitmap class.





Re: Visual C++ Express Edition Bitmap Clone problem

SPQR_ROME

But putting that line gives an error

1>..\Pixelembed V1_6 CLI.cpp(64) : error C2872: 'Bitmap' : ambiguous symbol

1> could be 'c:\windows\microsoft.net\framework\v2.0.50727\system.drawing.dll : System:Big Smilerawing::Bitmap'

1> or 'c:\program files\microsoft sdks\windows\v6.0\include\GdiplusHeaders.h(494) : Gdiplus::Bitmap'

Thanks





Re: Visual C++ Express Edition Bitmap Clone problem

nobugz

Sounds like you still have #include <gdiplus.h> in your code. Remove it, there's no point in keeping it when you switch to managed code. Or use the full name (System::Drawing::Bitmap).





Re: Visual C++ Express Edition Bitmap Clone problem

SPQR_ROME

I tryed to remove the #include <gdiplus.h> but it caused over 100 errors.

I used the full name (System:Big Smilerawing::Bitmap) and tryed to corrrect my code.

I managed to reduce it to 50 errors that I don't know how to fix such as :

1>..\Pixelembed V1_6 CLI.cpp(70) : error C2039: 'GetWidth' : is not a member of 'System:Big Smilerawing::Bitmap'

1> c:\windows\microsoft.net\framework\v2.0.50727\system.drawing.dll : see declaration of 'System:Big Smilerawing::Bitmap'

1>..\Pixelembed V1_6 CLI.cpp(71) : error C2039: 'GetHeight' : is not a member of 'System:Big Smilerawing::Bitmap'

1> c:\windows\microsoft.net\framework\v2.0.50727\system.drawing.dll : see declaration of 'System:Big Smilerawing::Bitmap'

1>..\Pixelembed V1_6 CLI.cpp(82) : error C2872: 'Rectangle' : ambiguous symbol

1> could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0\Include\wingdi.h(3667) : BOOL Rectangle(HDC,int,int,int,int)'

1> or 'c:\windows\microsoft.net\framework\v2.0.50727\system.drawing.dll : System:Big Smilerawing::Rectangle'

1>..\Pixelembed V1_6 CLI.cpp(127) : error C2664: 'System:Big Smilerawing::Bitmap::UnlockBits' : cannot convert parameter 1 from 'Gdiplus::BitmapData' to 'System:Big Smilerawing::Imaging::BitmapData ^'

1> No user-defined-conversion operator available, or

1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called





Re: Visual C++ Express Edition Bitmap Clone problem

nobugz

Sigh. You're mixing unmanaged and managed code. Choose one, mixing doesn't make sense.





Re: Visual C++ Express Edition Bitmap Clone problem

SPQR_ROME

Can you give me a refference how to sort it out

Thanks.





Re: Visual C++ Express Edition Bitmap Clone problem

Bite Qiu - MSFT

SPQR_ROME wrote:

1>..\Pixelembed V1_6 CLI.cpp(82) : error C2872: 'Rectangle' : ambiguous symbol

1> could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0\Include\wingdi.h(3667) : BOOL Rectangle(HDC,int,int,int,int)'

1> or 'c:\windows\microsoft.net\framework\v2.0.50727\system.drawing.dll : System:Big Smilerawing::Rectangle'

This errors shows how to sort it out, Rectangle can be either a GDI+ function or a .NET class, GDI+ is native while things like System:Big Smilerawing::Rectangle is managed, you used both libraries and it caused those errors. Pick one means either use .NET Framework Class Library or GDI+ to perform your image processing tasks.






Re: Visual C++ Express Edition Bitmap Clone problem

SPQR_ROME

Is there a list specifying which functions are .NET and which are native so I could compare the two and try to sort it out.

Thank you.





Re: Visual C++ Express Edition Bitmap Clone problem

nobugz

It's simple, just remove #include <gdiplus.h>