|
My ServerApp disconnected ClientApp, when ClientApp reconnect to ServerApp ,It's Show ,who knows!thanks!
|
|
|
|
|
You have a debugger, haven't you?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi guys,
I need to do the following in an application I'm developing using C++ and MFC:
1. Open an image of any of the major image formats (say Windows bitmap, Jpeg and PNG).
2. Conform it to a certain resolution. I have a strong preference for doing so without creating any resizing artefacts. I would like the result to be similar to the result you get by resizing an image in Photoshop, rather than the result you get when internet explorer renders and image at a resolution different to that of the image itself (that creates unsettling artefacts).
3. Convert to PNG, and then get a char pointer to a buffer containing the PNG file, so I can serialise the image as a blob in a database for later retrieval.
4. Retrieve the image from the database, and re-create the PNG image to be displayed in my MFC application.
How might this be best achieved? I'm not necessarily looking for precise instructions - guidelines may be enough. I have a preference for using lightweight third-party libraries distributed under liberal open source licenses (i.e. not a GPL library). If boost.GIL (generic image library) can help, I'd certain be receptive to that, as I already use boost a lot. That said, given my relatively simple needs even that may be overkill,
Regards,
Sternocera
|
|
|
|
|
Sternocera wrote: 1. Open an image of any of the major image formats (say Windows bitmap, Jpeg and PNG).
CImage[^]
Sternocera wrote: 2. Conform it to a certain resolution. I have a strong preference for doing so without creating any resizing artefacts. I would like the result to be similar to the result you get by resizing an image in Photoshop, rather than the result you get when internet explorer renders and image at a resolution different to that of the image itself (that creates unsettling artefacts).
Bicubic Interpolation[^]
Sternocera wrote: 3. Convert to PNG, and then get a char pointer to a buffer containing the PNG file, so I can serialise the image as a blob in a database for later retrieval.
Again, CImage. Use the Save[^] method to save to an IStream created on an HGLOBAL[^], i.e. an IStream that writes to memory. Use a null HGLOBAL to start with, then use GetHGlobalFromStream[^] to get the HGLOBAL that the stream eventually ended up allocating. Then use GlobalSize[^] to get the amount of memory used by the stream and GlobalLock[^] to access the memory.
Sternocera wrote: 4. Retrieve the image from the database, and re-create the PNG image to be displayed in my MFC application.
Load the blob into an HGLOBAL (allocate a global with the required size, lock it to get a pointer where you can write the blob contents, hten unlock it). Then create an IStream on that HGLOBAL and use CImage::Load[^] to read the IStream into a CImage.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart,
Good answer, great tagline,
Regards,
Sternocera
|
|
|
|
|
Stuart Dootson wrote: cubic Interpolation[^]
Stuart,
Can you suggest a practical way to use Bicubic interpolation to resize my CImage? Obviously it's preferable to use some proven third party library rather than re-inventing the wheel. Again, *any* guidance you can offer is helpful, I'm not necessarily looking for step-by-step instructions. Google has not been helpful here,
Regards,
Sternocera
|
|
|
|
|
CxImage[^] has plenty of interpolation algorithms. After some research, Lanczos resampling may be better than bicubic - CxImage does both.
[edit]FreeImage[^] is another image processing library with interpolation. The documentaton includes a section on choosing the right interpolation algorithm, which could be handy[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You might try my DLL [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I would like to change the icons for the items in the list control on the right hand pane of a project of mine using the Windows Explorer architecture (http://www.codeproject.com/KB/tree/SimpleDrvExplorer.aspx). I believe that an efficient way of doing this would be to use I_IMAGECALLBACK as described in this Microsoft support document (http://support.microsoft.com/kb/141834). However, I don't know how to find out what the child identifier is for my list control (the equivalent of IDI_LIST in the support article). This would be easy if, for instance, I had added the list control to a dialog form, or whatever, since the ID would be something I would have renamed when I added it. Perhaps the architecture of my program precludes me from being able to use the I_IMAGECALLBACK method, but I'd like to know.
Thanks,
Ben.
modified on Thursday, March 26, 2009 5:34 PM
|
|
|
|
|
One of my application uses windows scheduler to call a different application.
It is noted that the windows scheduler does not get invoked to run a program with some command line parameters.
Are there some restrictions in the usage of Windows scheduler that prevent from it getting invoked. The application works fine with all the machines except for this one.
|
|
|
|
|
If you've successfully created a scheduled task, you should be able to verify if it will run or not. If it does not, you can rule out any problems with your code.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am currently writing a multi-threaded application using C++ and MFC. The application has one GUI thread and several additional worker threads that are CPU intensive. Often, when the worker threads are running and the user clicks on the right hand corner of the window (to close the application) the program crashes.
At the moment, I am not processing the messages WM_CLOSE, WM_QUIT or WM_DESTROY. To remedy this crash, I am thinking about catching the message WM_CLOSE and shutting down the worker threads. Does this make sense? Should I be processing WM_QUIT or WM_DESTROY?
Thanks
Bob
|
|
|
|
|
BobInNJ wrote: To remedy this crash, I am thinking about catching the message WM_CLOSE and shutting down the worker threads
It looks like you should do it in response to WM_DESTROY , see here [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The other threads should run until either they finish or an event is signaled. When the application requests to close, it should signal an event and then wait for the other threads to end. Only then should the application quit.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have a shell namespace extension with a virtual junction point in the Desktop. I would like to use SHBrowseForFolder and set the root or initial directory to be in my shell namespace extension. I can set these to standard locations and browse into my extension, but I can't figure out how to start out there. As expected, I can do this type of thing with explorer and the file dialog using ::{extension CLSID} in my path. Does anyone know the trick for this?
|
|
|
|
|
Can't you create an IDLIST to your extension on the desktop? If you can you can use BFFM_SETSELECTION (see here[^]) to select your extension for the dialog, or you can feed it as a root using the BROWSEINFO[^] structure's pidlroot member.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
i have a run time error in Matrix ADT
i hope u help me to find out this problem and how i can fix it
template <typename t="">
Matrix<t> Matrix<t>::Addition(Matrix<t> rhs)
{
if((rhs.numRows!=numRows)||
(rhs.numColumns!=numColumns))
{
cout<<"Rows and columns must be in same degree";
exit(1);
}
else
{
int r,c;
Size(r,c);
Matrix<t> addResult;
addResult.MemAlloc(r,c);
for(int rows=1;rows<=numRows;rows++)
{
for(int columns=1;columns<=numColumns;columns++)
{
addResult.elements[rows][columns]=elements[rows][columns]+
rhs.elements[rows][columns];
}
}
return addResult;
}
}
</t></t></t></t></typename>
the complete ADT and test driver here
http://www.4shared.com/file/94365985/33928f79/Matrix.html[^]
http://www.4shared.com/file/94365991/2de47a21/MatrixTestDriver.html[^]
|
|
|
|
|
Member 4189605 wrote:
for(int rows=1;rows<=numRows;rows++)
{
for(int columns=1;columns<=numColumns;columns++)
{
addResult.elements[rows][columns]=elements[rows][columns]+
rhs.elements[rows][columns];
}
}
So - you might be interested to know that C/C++ uses zero-based arrays, not one-based arrays?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Welcome in the CP's memorable quotes list [^], Stuart.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
what is the problem if i start to use from 1 index ....?? that's not the problem
i think the problem in Memory Allocation for Addition Function and Copy Function
also there is divide by zero in ToUpper() but i don't care to it
iam interesting fixing Addition and Copy Functions
thnx for your reply
|
|
|
|
|
Nothing soooo bad, actually, but you're wasting the first element of the array, and, of course, you've declare the array having needed itemss plus one if you don't want to go out of bounds in your loops, for instance
#define N 10;
int a[N+1];
int i;
for (i=1; i<=N; i++)
{
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
Here is the situation. We have this driver box that we can communicate via USB using the libraries provided by the manufacturer. The library came with a .tlb, /lib and .h file and its written based on COM model and requires ATL support. So, in VC++ I can just create a MFC application and add an ATL object, include the .h file, import the .tlb file and create CComPtr variable derived for their object for the driver and communicate with the driver through that object. Everything works fine.
But now I need to use the library that they provided in LabWindows CVI where these libraries wont work. It doesnt have ATL support. I tried creating a MFC applciaiton where it listens to the serial port and CVI sending commands to the MFC application via serial port, but this is slow.
Is there any other way where I can create something that can be added into CVI as an object without bothering about the stuff in the object other than just communicating with it within the CVI program (ActiveX??).
thanks in advance.
PKNT
|
|
|
|
|
Usually you don't need either MFC nor ATL to cunsume COM components.
On LabWindows CVI website there are samples about using ActiveX components, see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Thursday, March 26, 2009 3:05 PM
|
|
|
|
|
Actually its not an ActiveX object, I just thought if I can use that type to interate in CVI.
Here is what the driver manual said,
"The Driver USB Library is implemented as an object that conforms to Microsoft's Component Object Model (COM). A COM object is an instance of a COM class. Clients interact with a COM object only through its interfaces.
To create an instance of the COM object in a C++ program, include the following lines of code in your program:"
#include "..\DriverUsbLib\DriverUsbLib.h"
#import "..\DriverUsbLib\_DriverUsbLib.tlb" no_namespace
using namespace std;
CComPtr<ihostdrv> pIHostDrv;
HRESULT hr = CoCreateInstance(__uuidof(CHostDrv), NULL, CLSCTX_INPROC,
__uuidof(IHostDrv),(LPVOID *) &pIHostDrv);</ihostdrv>
I was not able to do the same thing in CVI. I tried to search on NI forums, but couldnt get any useful info on dealing with COM objects. Will keep looking on it.
thanks,
PKNT
|
|
|
|
|
I'm having trouble with getting search results from Active Directory since I installed Microsoft Echange. After Exchange installation the enum order changed so that child SOME objects are enumerated before parent. Before installing Exchange everything was OK. Now I want to fix this behavior with following piece of code (but currently unsuccessfull). The flag LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER does not work for me.
Here is the piece of code:
void ImportComputersFromAd()
{
CComPtr<IDirectorySearch> pSearch;
HRESULT hr = ::ADsGetObject(L"LDAP://DC=mydomain", IID_IDirectorySearch, (PVOID*)&pSearch);
ADS_SEARCHPREF_INFO rgSearchPrefs[4];
DWORD dwNumPrefs = 0;
rgSearchPrefs[dwNumPrefs].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
rgSearchPrefs[dwNumPrefs].vValue.dwType = ADSTYPE_INTEGER;
rgSearchPrefs[dwNumPrefs].vValue.Integer = ADS_SCOPE_SUBTREE;
dwNumPrefs++;
ADS_PROV_SPECIFIC dirsync;
dirsync.dwLength = 0;
dirsync.lpValue = NULL;
rgSearchPrefs[dwNumPrefs].dwSearchPref = ADS_SEARCHPREF_DIRSYNC;
rgSearchPrefs[dwNumPrefs].vValue.dwType = ADSTYPE_PROV_SPECIFIC;
//rgSearchPrefs[dwNumPrefs].vValue.ProviderSpecific.dwLength = sizeof(dirsync);
rgSearchPrefs[dwNumPrefs].vValue.ProviderSpecific = dirsync;
dwNumPrefs++;
rgSearchPrefs[dwNumPrefs].dwSearchPref = ADS_SEARCHPREF_DIRSYNC_FLAG;
rgSearchPrefs[dwNumPrefs].vValue.dwType = ADSTYPE_INTEGER;
rgSearchPrefs[dwNumPrefs].vValue.Integer = LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER;
dwNumPrefs++;
hr = pSearch->SetSearchPreference(rgSearchPrefs, dwNumPrefs);
LPOLESTR pszAttribute[] = { L"ADsPath"};
CONST DWORD dwAttrNameSize = 1;
ADS_SEARCH_HANDLE hSearch;
hr = pSearch->ExecuteSearch(L"(|(objectClass=computer)(objectClass=organizationalUnit))", pszAttribute, dwAttrNameSize, &hSearch);
while(pSearch->GetNextRow(hSearch) != S_ADS_NOMORE_ROWS)
{
for(DWORD x = 0; x < dwAttrNameSize; x++)
{
ADS_SEARCH_COLUMN col;
HRESULT hr2 = pSearch->GetColumn(hSearch, pszAttribute[x], &col);
if(hr2 != E_ADS_PROPERTY_NOT_FOUND // 0x8000500d - The directory property cannot be found in the cache
&& hr2 != 0x8007200a // The specified directory service attribute or value does not exist.
&& hr2 != E_ADS_COLUMN_NOT_SET //0x80005010 - The specified column in the Active Directory was not set.
&& hr2 != 0x80005008)
{
CComPtr<IADs> srpiads;
hr2 = ::ADsGetObject(col.pADsValues->CaseIgnoreString, IID_IADs, (PVOID*)&srpiads);
//pThis->AddComputerProperties(srpiads);
pSearch->FreeColumn(&col);
}
}
}
pSearch->CloseSearchHandle(hSearch);
}
|
|
|
|
|