|
void *a = new CArray<int,>;
CArray<int,> *q = (CArray<int,> *) a;
delete q;
Without digging into more detail than I care about, deleting a void * gives you trouble, as void is zero length, but you allocated a chunk of ram of a certain length. Also, void * won't have a destructor, so any clever things done inside CArray would not be tidied up.
Not so fussed about tea - got that already - but Iain wanna bikkit!
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Wait, the delete still crashes.
CItemData::CItemData(ItemType type, CArray<Gdiplus::PointF> *pFig)
{
m_type = type;
m_pFig = pFig;
}
CItemData::~CItemData()
{
delete m_pFig;
}
|
|
|
|
|
followait wrote: Wait, the delete still crashes.
1/ You missed out how your item is initialised: ie, where pFig comes from.
2/ The following code works just fine.
class CItemData
{
public:
CItemData (CArray<int,int&> *pFig)
{
m_pFig = pFig;
}
~CItemData()
{
delete m_pFig;
TRACE0("m_pFig deleted nicely\n");
}
protected:
CArray<int,int> *m_pFig;
};
CItemData i (new CArray<int,int&>);
I made the array a simple one, as I couldn't be fussed finding my gdiplus headers. I also make sure that pFig has been allocated with new - is that true for your code?
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
is the object pointed to by m_pFig deleted twice?
Mark
|
|
|
|
|
Yes
|
|
|
|
|
Well there's your problem right there
|
|
|
|
|
I have a filename like "D:\\myfolder\\aaaa.avi".
I have to extract the name of the avi file.have searched.but found methods for extracting only the first half.i use vc++
|
|
|
|
|
See PathFindFileName()[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Modified: Rajesh's answer is better - and has a link!
PathStripPath is your friend.
Or you could do it manually by putting the text into a CString, and using Find ('\\') and Mid to strip it away - but you might miss out on wacky things like /s, etc. Get the shell development people to do the heavy lifting for you!
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Can you use of FindFirstFile?
|
|
|
|
|
Hi all,
I m using a Validation for any CString type variable of Edit box control.
CString str;
if(str=="")
{
AfxMessageBox("It should not be blank");
}
if it is blank than it is working properly.
if i use only space in edit control.(there is no text only space is used)
than it not gives error please tell me how can i check it in case of space .
Please help me for this .
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
if (str.trim().IsEmpty()) {
}
modified on Thursday, June 26, 2008 5:32 AM
|
|
|
|
|
toxcct wrote: if (str.trim().empty()) {
I guess you mean str.Trim().IsEmpty() . isn't it?
|
|
|
|
|
|
Hi
I have been fighting with this for days moving from random error to random error.
I am trying to write what is effectively a software driver for a decklink blackmagic capture card using the directshow api.
The code I have here is basically the sample code from the MSDN website to get all the video devices on the system
but I just seem to get errors everytime I try to compile this!
#pragma once
#include "stdafx.h"
#define DllExport __declspec(dllexport)
#pragma comment(lib,"Strmiids.lib")//Includes the directshow library
class VideoCapture
{
public:
VideoCapture(void);
void getNames();
void getDevice();
void createFilter();
public:
~VideoCapture(void);
};
#include "stdafx.h"
#include "VideoCapture.h"
#include "dshow.h"
#include "Atlbase.h"
#include "Atlcom.h"
#ifdef _MANAGED
#pragma managed(push, off)
#endif
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
#ifdef _MANAGED
#pragma managed(pop)
#endif
VideoCapture::VideoCapture(void)
{
}
VideoCapture::~VideoCapture(void)
{
}
ICreateDevEnum *pDevEnum;
IEnumMoniker *pEnum =NULL;
HWND hList;
IMoniker *pMoniker = NULL;
IFilterGraph *m_pGraph=NULL;
VARIANT varName;
IPropertyBag *pPropBag = NULL;
HRESULT hr;
__declspec(dllexport) void __cdecl getDevice()
{
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
reinterpret_cast<void**>(&pDevEnum));
if (SUCCEEDED(hr))
{
hr = pDevEnum->CreateClassEnumerator(
CLSID_VideoInputDeviceCategory,
&pEnum, 0);
}
}
__declspec(dllexport) void __cdecl getNames()
{
while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
{
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
(void**)(&pPropBag));
if (FAILED(hr))
{
pMoniker->Release();
continue;
}
VariantInit(&varName);
hr = pPropBag->Read(L"Description", &varName, 0);
if (FAILED(hr))
{
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
}
if (SUCCEEDED(hr))
{
USES_CONVERSION;
(long)SendMessage(hList, LB_ADDSTRING, 0,
(LPARAM)OLE2T(varName.bstrVal));
VariantClear(&varName);
}
pPropBag->Release();
pMoniker->Release();
}
}
__declspec(dllexport) void __cdecl createFilter()
{
IBaseFilter *pCap = NULL;
hr = pMoniker->BindToObject(0,0,IID_IBaseFilter,(void**)&pCap);
if (SUCCEEDED(hr))
{
hr = m_pGraph->AddFilter(pCap,L"Capture Filter");
}
}
It seems determined to return this error to me no matter what order I put the includes in at the top, and if I put one of them completely out of place i get around 114 errors returned back to me
The error is:
Fatal error c1189: #error : Need to include strsafe.h after tchar.h
any help with this would be greatly appreciated
Cheers
boyindie
|
|
|
|
|
What's in your stdafx.h file?
You also shouldn't be including stdafx.h in your VideoCapture.h file
if stdafx.h is used for a pre-compiled header.
Mark
|
|
|
|
|
dear all
how to calculate each columns 255 value amount and then save a .txt file? the example is following:
0 0 0 0 0 0 0
0 0 255 255 255 255 255
0 0 255 255 255 255 255
0 0 255 255 255 255 255
0 0 255 255 255 255 255
0 0 255 255 255 255 255
0 0 0 0 0 0 0
for example: i want to get: 255 amount below:
arryOne = columns 3 4 5 6 7
amount 5 5 5 4 4
how to get such the form of value?
thanks a lot
gentleguy
modified on Thursday, June 26, 2008 5:29 AM
|
|
|
|
|
What?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
thanks for your reply, sorry, the format changed there, actually i would like to calculate each column 255 amount, and then save an file: first row displays columns number and second row display amount of 255. however i revised the format,, it is still problem. do you understand me? thanks for your help in advance.
gentleguy
|
|
|
|
|
Iterate over each column and count the number of times 255 occur. Isn't that simple?
-Saurabh
|
|
|
|
|
thanks for your reply, i am a newbie, could you give me detail or some code, thanks a lot.
gentleguy
|
|
|
|
|
thanks for reply, for me maybe i have 400 or 700 hundrads columns,i load binary image, maybe 300x600 or evern big than this one...
i am a newbie, can give me examlpe.thanks
gentleguy
|
|
|
|
|
Can you tell us how do you declare this 2D array? I will give you a hint for static 2D array in C++.
int array[100][100];
int count[100];
for(int i=0 ; i<100 ; ++i)
{
count[i] = 0;
}
for(int i=0 ; i<100 ; ++i)
{
for(int j=0 ; j<100 ; ++j)
{
if(array[i][j] == 255)
{
count[j]++;
}
}
}
Hope this helps.
-Saurabh
|
|
|
|
|
thanks for your help, my data is from binary image, different binary image has different dimension, when i load one 2-D binary image, depend on image size, but i can obtain width and height of image via access image definition. do you understand me? i can declare a 2-D dinamic array.thanks
unsigned char *ucImgdata1 =m_vicImg.ibuff;
int iWidth1 = m_vicImg.endx-m_vicImg.stx+1;
int iHeight1 = m_vicImg.endy-m_vicImg.sty+1;
int iWidthbyte1=m_vicImg.buffwidth;
int *nColumnCounts=new int[iWidth1];
for (int i=0;i<iwidth1;iwidth1;i++)
{
nColumnCounts[i]=0;
}
for(int iY=0;iY<iheight;iheight1;iy++)
{
for(int iX=0;iX<iwidth1;iwidth1;ix++)
{
if (imgArray [iX+iY*iwidth1] == 255)
{
nColumnCounts[iX]++;
FILE* stream;
stream=fopen("C:\\TestArray.txt","w");
fprintf(stream," Array=%d\n",nColumnCounts[iX]);
fclose(stream);
}
}
but i couldn't get the correct result. i would like to get one array including how many amount of 255 for each column.help me,thanks.
gentleguy
modified on Sunday, June 29, 2008 4:53 AM
|
|
|
|
|
thanks a lot, i still get the correct result. but my data format is a little different.
the detail is following:
unsigned char *ucImgdata1 =m_vicImg.ibuff;
int iWidth1 = m_vicImg.endx-m_vicImg.stx+1;
int iHeight1 = m_vicImg.endy-m_vicImg.sty+1;
int iWidthbyte1=m_vicImg.buffwidth;
int *nColumnCounts=new int[iWidth1];
for (int i=0;i<iwidth1;i++)
{ nColumnCounts[i]=0;
}
for(int iY=0;iY<iheight1;iy++)
{
for(int iX=0;iX<iwidth1;ix++)
{
if (imgArray [iX+iY*iWidth1] == 255)
{
nColumnCounts[iX]++;
FILE* stream;
stream=fopen("C:\\TestArray.txt","w");
fprintf(stream," Array=%d\n",nColumnCounts[iX]);
fclose(stream);
}
}
}
could help me? thanks
gentleguy
|
|
|
|