The Image is being displayed upside down :(
-
If you're using C++/CLI, you have no need of FreeImage, .NET will load all the image formats you're likely to need, and save them too. Windows bitmaps are stored bottom line first. Perhaps FreeImage is inverting them ? Christian Graus - Microsoft MVP - C++
Dear Sir, May be it's inverting it, but is there any cure? However I still have to use FreeImage, since I am working on an image processing application and all the code has to be in Standard C (so that it can be ported easily), I am using CLR/.NET only because I need a good looking interface. - A programmer's national anthem; "AAAAAHHHHH!!!!"
-
Dear Sir, May be it's inverting it, but is there any cure? However I still have to use FreeImage, since I am working on an image processing application and all the code has to be in Standard C (so that it can be ported easily), I am using CLR/.NET only because I need a good looking interface. - A programmer's national anthem; "AAAAAHHHHH!!!!"
signbit wrote:
May be it's inverting it, but is there any cure?
Not short of inverting it back :-)
signbit wrote:
all the code has to be in Standard C (so that it can be ported easily),
What, for the 3 people in the world using Linux who pay for software, or the 50 odd who do the same for Mac ?
signbit wrote:
), I am using CLR/.NET only because I need a good looking interface.
That's just silly. You don't need CLR to make your UI look good, they had good looking UIs long before .NET existed. Christian Graus - Microsoft MVP - C++
-
Hello, I am creating a Bitmap with the following code:
image = gcnew Bitmap(FreeImage_GetWidth(document->currentImage),
FreeImage_GetHeight(document->currentImage), FreeImage_GetLine(document->currentImage),
System::Drawing::Imaging::PixelFormat::Format24bppRgb,
(IntPtr)FreeImage_GetScanLine(document->currentImage, 0));Image information (Height, Width, ScanLine0 and etc) is obtained from FreeImage (the open source library I am using for image handling). When the image is displayed, it displays upside down, can any one tell me what might be the problem, how can I make it correct? I'll be grateful. - A programmer's national anthem; "AAAAAHHHHH!!!!"
Windows bitmaps are normally "upside down", but Windows understands normal (upside down) bitmaps as well as "right-way-up" bitmaps - check the MSDN documentation on bitmap headers. As far as I remember, "right-way-up" bitmaps have negative height, so in your code, try changing:
info.biHeight = height;
to
info.biHeight = -height;
(or whatever the equivalent is in C++.) I use this technique with a StretchDIBits call, and it works there, but it may not work with all display APIs.
-
Dear Sir, May be it's inverting it, but is there any cure? However I still have to use FreeImage, since I am working on an image processing application and all the code has to be in Standard C (so that it can be ported easily), I am using CLR/.NET only because I need a good looking interface. - A programmer's national anthem; "AAAAAHHHHH!!!!"
Also, If I use the following code for image creation, it works just fine. But I don't like this code, it's a 4 step procedure and it should be liking the processor very much.
if(image)
delete image;FIMEMORY *hMem;
hMem = FreeImage_OpenMemory();
FreeImage_SaveToMemory(FIF_BMP, document->currentImage, hMem);BYTE *pBuffer;
DWORD size;FreeImage_AcquireMemory(hMem, &pBuffer, &size);
UnmanagedMemoryStream^ memStream =
gcnew UnmanagedMemoryStream(pBuffer, size);
image = gcnew Bitmap(memStream);FreeImage_CloseMemory(hMem);
- A programmer's national anthem; "AAAAAHHHHH!!!!"
-
signbit wrote:
May be it's inverting it, but is there any cure?
Not short of inverting it back :-)
signbit wrote:
all the code has to be in Standard C (so that it can be ported easily),
What, for the 3 people in the world using Linux who pay for software, or the 50 odd who do the same for Mac ?
signbit wrote:
), I am using CLR/.NET only because I need a good looking interface.
That's just silly. You don't need CLR to make your UI look good, they had good looking UIs long before .NET existed. Christian Graus - Microsoft MVP - C++
A couple of things: One can make a good interface even in WIN32 API (I have worked on it, and I am sure I can). But we now longer make it, do we? why? we need the ease... Yes, I am using CLR only because It supports Windows Forms and I can concentrate on core algorithms when I don't have to worry for the UI. There is a lot of speed difference between Managed and Unmanaged code (MS may have made several gaint steps in improving it's CLR but still it's a layer between You and the processor). If I had luxeries on that, I would have used C# in first place, I am using VC++ because I can access/write the C code more easily here. There is a chance that the application may have to be burned into some custome hardware (and only C can be burned into HW at this time). Yes I need to care about those 3 people who use Linux because it doesn't harm me. doest it? :) - A programmer's national anthem; "AAAAAHHHHH!!!!" -- modified at 0:38 Tuesday 28th February, 2006
-
Windows bitmaps are normally "upside down", but Windows understands normal (upside down) bitmaps as well as "right-way-up" bitmaps - check the MSDN documentation on bitmap headers. As far as I remember, "right-way-up" bitmaps have negative height, so in your code, try changing:
info.biHeight = height;
to
info.biHeight = -height;
(or whatever the equivalent is in C++.) I use this technique with a StretchDIBits call, and it works there, but it may not work with all display APIs.
-
A couple of things: One can make a good interface even in WIN32 API (I have worked on it, and I am sure I can). But we now longer make it, do we? why? we need the ease... Yes, I am using CLR only because It supports Windows Forms and I can concentrate on core algorithms when I don't have to worry for the UI. There is a lot of speed difference between Managed and Unmanaged code (MS may have made several gaint steps in improving it's CLR but still it's a layer between You and the processor). If I had luxeries on that, I would have used C# in first place, I am using VC++ because I can access/write the C code more easily here. There is a chance that the application may have to be burned into some custome hardware (and only C can be burned into HW at this time). Yes I need to care about those 3 people who use Linux because it doesn't harm me. doest it? :) - A programmer's national anthem; "AAAAAHHHHH!!!!" -- modified at 0:38 Tuesday 28th February, 2006
signbit wrote:
Yes I need to care about those 3 people who use Linux because it doesn't harm me. doest it?
And yet, here you have an issue because you're using third party libraries. An issue that would go away if you were not concerned about cross platform code. So yes, it does hurt you. It costs you time and it costs you options. Christian Graus - Microsoft MVP - C++
-
signbit wrote:
Yes I need to care about those 3 people who use Linux because it doesn't harm me. doest it?
And yet, here you have an issue because you're using third party libraries. An issue that would go away if you were not concerned about cross platform code. So yes, it does hurt you. It costs you time and it costs you options. Christian Graus - Microsoft MVP - C++
No It doesn't, since if using 3rd party libraries and portable code would have been an issue, we wouldn't have this forum full of messages that target the problems for pure CLR/.NET code. It's just any other problem that I would have been facing during my development. and does it cost me options? ;) Nah, I have the option of porting my library to any platform I choose, I don't need to stick to Windows, So I have more options... Anyway, I think I am getting away from the original problem, won't be reply any such messages because It's not a debate. - A programmer's national anthem; "AAAAAHHHHH!!!!"
-
Windows bitmaps are normally "upside down", but Windows understands normal (upside down) bitmaps as well as "right-way-up" bitmaps - check the MSDN documentation on bitmap headers. As far as I remember, "right-way-up" bitmaps have negative height, so in your code, try changing:
info.biHeight = height;
to
info.biHeight = -height;
(or whatever the equivalent is in C++.) I use this technique with a StretchDIBits call, and it works there, but it may not work with all display APIs.
-
What is correct? giving negative height? I did that and CLR returned an exception... - A programmer's national anthem; "AAAAAHHHHH!!!!"
-
the post from 'normanS' was correct. It is possible to store images in a reverse line order. To indentify that the header contains a negative image size. If your library crashes there is something wrong in your libraries.
-
the post from 'normanS' was correct. It is possible to store images in a reverse line order. To indentify that the header contains a negative image size. If your library crashes there is something wrong in your libraries.