|
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!!!!"
|
|
|
|
|
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!!!!"
|
|
|
|
|
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
|
|
|
|
|
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!!!!"
|
|
|
|
|
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!!!!"
|
|
|
|
|
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,
Yup! I know the structure, I tried to trick CLR with that (i.e. negative height), but It didn't work out.
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
This is correct! If it doesn't work there is something wrong with your used libraries.
|
|
|
|
|
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.
|
|
|
|
|
Thanks for the support.
Unfortunately, many libraries do not support negative heights. This monster called Windows is just to big for most companies to keep up. This includes some Microsoft SDK stuff.
|
|
|
|
|
I said it's not my libraries that crash, it's .NET that crashes (my library returns the values as expected)
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
Hi All,
Good Morning Everybody!!!
I have some doubt about CDocument class.
Everyone of us know that CDocument is a class inheited directly from CCmdTarget and CCmdTarget class inturn is responsible for handling all the message(windows messages/control messages/command messages). Whereas CView class is inherited from CWnd which in turn is inherited from CCmdtarget class. So ultimately CDocument class(which is directly have the capabilities of handling any type of messages right??. Then why does in DV architecture the CView class is handling all the messages??
Thanks
|
|
|
|
|
Subramaniam s.V. wrote: hen why does in DV architecture the CView class is handling all the messages??
Because Windows sends messages to windows. Documents are not windows.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Accepted Ryan.
But my doubt is why doesnt it have the capabilities to handle the messages evethough it is derived from CCmdTarget directly.
|
|
|
|
|
I think CDocument only inherite from CCmdTarget, but not inherite from CWnd.
I think it's MFC designer's intention. I think CDocument is a kind of data, so it only should not handle some user interface message. Are you agree with it?
|
|
|
|
|
It does. You can add menu/toolbar item message handlers to your document class. MFC has some internal magic that will route it to the document's handler if the view doesn't process the message.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Iuse Administrator to Logged on My widnow xp.
I enum the share printer connected in the network.
I use openprinters() to open the printer ,it success.
I get the printer handle.
then I use FindFirstPrinterChangeNotification() to Monitor the printer ,it fail ,the Error code is 5(ERROR_ACCESS_DENIED).
but if Use the domain user to logged on my window xp(just like: domain1\\user1),
all is good .
why?
what different between of administrator(local) and domain1\\user1(domain)?
how to fix it?
thanks!
my code like this:
hPrinterNotification = FindFirstPrinterChangeNotification(
ThreadParam.hPrinter,
PRINTER_CHANGE_DELETE_JOB,
0,
&NotificationOptions);
if (hPrinterNotification == INVALID_HANDLE_VALUE)
{
CString strE;
strE.Format ("FindFirstPrinterChangeNotification failed! Error code = %d",GetLastError());
return 0;
}
-- modified at 21:47 Monday 27th February, 2006
|
|
|
|
|
Your local administrator account does not necessarily have privileges on the network.
It is possible to enumerate network resources without having necessary permission to access or utilize those resources.
So, you can enumerate the printers, but when you try to open one, you fail from the local administrator account. Your domain account obviously has network printer privileges.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Blake Miller:
can you tell how to open one from the local administrator account?
thanks!
cococut
|
|
|
|
|
The same way you open the other ones, but you have to be granted access permission form the owner of the object, in this case the printer.
In other words, a network administrator needs to grant the MachineName\Administrator account privileges to modify the printer.
Also, you could try different access permission request, instead of ALL_ACCESS try something like 'read' access rights on the OpenPrinter command, that might work, since you are perhaps not trying to change anything.
Most people seem to go for ALL_ACCESS when they only want to query a device. Opening for read only access often works where 'all access' or 'write access' requests fail.
You could post the code for your OpenPrinter command and me or someone here could try to help you out.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Does anyone know why a c++ mfc exe would run without displaying it's form?
Unfortunately I don't have the source.
|
|
|
|