|
sir now one more issue occur here when i print with multiple page.
on first page its drawimage correctly but after first page it return generic error.
i really dont understand what happen here.
please help me for this.
thanks in advance.
|
|
|
|
|
I suggest you open a new question, and provide proper details of both code and error. You can help to isolate the problem by using your debugger to step through your code.
|
|
|
|
|
Hi Friends,
My application don't want to create any entry in registry. If I comment SetRegistryKey(_T("Local AppWizard-Generated Applications")) then application throw an Assert failure. How to overcome from this problem.
Thanks,
S Shanmuga Raja
|
|
|
|
|
First show exactly what code is causing the assert; we cannot see your screen.
|
|
|
|
|
Richard MacCutchan wrote: we cannot see your screen. Come on, Richard, upgrade to the latest version so you can at least pretend to help. ScreenPeek v2.0 has been out for several months now.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I tried CrystalBall 1.1 but its all blurred.
|
|
|
|
|
shanmugarajaa wrote: ...then application throw an Assert failure. Exactly what assertion is being thrown?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi Friends,
Where FindFirstFile function fetching all folders, sub folders and files details? whether this API fetching information from registry?
Thanks,
S Shanmuga Raja
|
|
|
|
|
No, it performs the same function as the command line command dir, and lists all files as specified by the selection mask. This is explained in detail in the MSDN documentation[^].
|
|
|
|
|
That's part of the underlying file system, be it FAT32 or NTFS. See here for the latter.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I have a MFC dialog application in which I have a gdiplus object that I use to draw images in real-time. Works fine if I don't want to do any changes to this object or its associated variables. But when I try to update them at runtime, it starts to increase my memory consumption.
So, my question is, how to safely update a gdiplus object at runtime.
Here is my code
LONG Width;
LONG Height;
LONG bpp;
LONG Stride;
BITMAPINFO* bmi;
BYTE* pDIBSectionBits;
HBITMAP hbm;
Graphics* imagedisp;
Bitmap* offscreenBitmap;
CWnd* Display;
CStatic m_ImageDisp;
OnInitDialog()
{
......
Width = 512;
Height = 512;
bpp = 8;
Stride = ((Width * bpp + 31L) & (~31L)) / 8L;
......
}
InitParams()
{
SetImageColor();
Display = GetDlgItem(IDH_IMAGE);
this->GetClientRect(&m_disp_rect);
Display->GetClientRect(&m_disp_rect);
m_ImageDisp.GetClientRect(&m_disp_rect);
imagedisp = new Graphics(m_ImageDisp.GetDC()->GetSafeHdc());
}
SetImageColor()
{
m_BUpdate = false;
if (bmi != NULL)
{
delete bmi;
bmi = NULL;
}
bmi = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFO) + UCHAR_MAX * sizeof(RGBQUAD)];
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi->bmiHeader.biWidth = Width;
bmi->bmiHeader.biHeight = Height;
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biBitCount = (WORD)bpp;
bmi->bmiHeader.biCompression = BI_RGB;
bmi->bmiHeader.biSizeImage = 0; bmi->bmiHeader.biXPelsPerMeter = 0;
bmi->bmiHeader.biYPelsPerMeter = 0;
bmi->bmiHeader.biClrUsed = 0;
bmi->bmiHeader.biClrImportant = 0;
memcpy(bmi->bmiColors, USECOLORMAP?summercmap:greyscale, 256*sizeof(RGBQUAD));
hbm = ::CreateDIBSection(NULL, bmi, DIB_RGB_COLORS, (void**)&pDIBSectionBits, NULL, 0);
if (offscreenBitmap != NULL)
{
delete offscreenBitmap;
offscreenBitmap = NULL;
}
offscreenBitmap = new Bitmap(bmi, pDIBSectionBits);
m_BUpdate = true;
}
OnPaint()
{
CPaintDC dc(this); if (m_BUpdate)
{
BYTE *pCurRowPixel = (BYTE *)(pDIBSectionBits);
memcpy(pCurRowPixel, ImgBuff, Width*Height);
imagedisp->DrawImage(offscreenBitmap, 0, 0, Width, Height);
}
}
So whenever the user clicks a button to change between grayscale and color pallette, SetImageColor() is called. When I monitor the memory usage while clicking that button, I see its changing the way I expect it to, but the memory usage keeps increasing at a rate of ~300KB per click.
Is there any safer way to achieve what I am trying to do without memory leaks?
thanks
PKNT
modified 26-Feb-16 14:31pm.
|
|
|
|
|
do you ever call DeleteObject on the result from that CreadeDIBSection ? (you should)
|
|
|
|
|
Thanks Chris, that solved my memory leak issue.
PKNT
|
|
|
|
|
When I am trying run program, command line for ubuntu generation error that.
I'm trying run compline program with command /build/LSB/LSB$ ./thanhtmLSBext Girl.emb.bmp
This is code of my:
File c: thanhtmLSBext.c
include <stdio.h>
include <cv.h>
include <cxcore.h>
include <cvaux.h>
include <highgui.h>
int *alloc_int_1D(int rows);
void free_int_1D(int *array);
int main(int argc, char** argv)
{
int i, j, n = 0;
IplImage* img;
FILE *fp;
int fp_size;
int wm;
char filename = argc >= 2 ? argv[1] : (char*)"Girl.emb.jpg";
if( (img = cvLoadImage( filename, 1)) == 0 )
return -1;
fp = fopen( "extract.gray", "wb" );
if( fp == NULL )
{
puts( "extract.grayが開けません" );
return -1;
}
wm = (int *)alloc_int_1D(64*64*10);
for(i = 0; i < 64*64*10; i++){
wm[i] = 0;
}
CvScalar s;
int h=img->height;
int w=img->width;
for(i=0; i<w;> for(j=0; j<h;> s=cvGet2D(img,i,j);
wm[n] = (int)(s.val[0])%2;
fputc(wm[n]255,fp);
n++;
}
}
cvReleaseImage(&img);
free_int_1D(wm);
fclose(fp);
return 1;
}
/
IplImage* embed(IplImage *img, int wm, int N){
IplImage img1;
int i, j, n = 0;
img1 = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 3);
CvScalar s,s1;
int h=img->height;
int w=img->width;
for(i=0; i<w;> for(j=0; j<h;> s=cvGet2D(img,i,j);
s1.val[0]=s.val[0] + (double)wm[n%N]/255 - (double)((int)(s.val[0])%2);
s1.val[1]=s.val[1];
s1.val[2]=s.val[2];
cvSet2D(img1,i,j,s1);
n++;
}
}
}
*/
int *alloc_int_1D(int rows) {
int *p;
p = (int *)malloc(rows * sizeof(int));
if (!p) {
ifdef DEBUG
fprintf(stderr, "alloc_int(): malloc() failed\n");
exit(1);
else
return NULL;
endif
}
return p;
}
void free_int_1D(int *array) {
free(array);
}
I hope everybody will help me. Thanks you.
|
|
|
|
|
char filename = argc >= 2 ? argv[1] : (char)"Girl.emb.jpg";
I stopped reading the unformatted code after this point but it is very probable that this is the reason for the segmentation fault.
It should be:
const char * filename = argc >= 2 ? argv[1] : "Girl.emb.jpg";
I strongly recommend to use the -Wall GCC option when compiling and don't start the program while there are any warnings.
Then you should have a got a lot of warnings with your code; at least in the next line
if( (img = cvLoadImage( filename, 1)) == 0 )
where you are passing the char variable filename where a char * is expected.
|
|
|
|
|
Hello,
Mine is a project in Visual C++, in which I am using STL, and trying to use the "find" algorithm with vectors. But it's giving me the error, error C2678: binary '==' : no operator found which takes a left-hand operand of type 'xyz' (or there is no acceptable conversion), because I have an app class in MFC which has a structure 'xyz' whose only member is a BYTE array. I am trying to get the iterator position by finding a value in a vector of a user-defined type and in return I am getting the above error. Hence a problem. Please help.
OR
someone can also suggest, which algorithm should I use to get the iterator position of the value I am searching for,from a vector of a user-defined data type (you can suggest that algorithm from the boost library also)?
Please help.
Thanks in advance. This is urgent.
Here is the relevant code snippet to understand the problem:
In the header,
typedef struct xyz
{
BYTE byHex[16];
}XYZ;
class CMyApp : public CWinApp
{
-----
------
public:
vector<XYZ> m_vec;
-------
--------
DECLARE_MESSAGE_MAP()
};
And in the implementation, in .cpp,
BYTE byBuff[16] = {0};
vector<XYZ> ::iterator viter;
viter = find(theApp.m_vec.begin(), theApp.m_vec.end(), byBuff);
And, here this "find" algorithm is giving me problems.
-- modified 26-Feb-16 7:29am.
|
|
|
|
|
Implement the equal (==) operator for your xyz class and the type on the right side.
To get more help you should show us the relevant code (the operation, the structure, and the right side type). To do this edit your initial question to add this information.
|
|
|
|
|
As already suggested implement the equal operator. This requires changing the typedef struct to a struct (in fact a class):
struct xyz
{
BYTE byHex[16];
bool operator==(const xyz& other)
{
return 0 == memcmp(other.byHex, this->byHex, sizeof(this->byHex));
}
bool operator==(const BYTE buf[16])
{
return 0 == memcmp(buf, this->byHex, sizeof(this->byHex));
}
};
Then use it as before:
BYTE byBuff[16] = {0};
vector<xyz> m_vec;
vector<xyz> ::iterator viter;
viter = std::find(m_vec.begin(), m_vec.end(), byBuff);
|
|
|
|
|
Many thanks for this solution, I fully appreciate it. Coincidentally, I had already implemented this, but since this was taking time in checking a database which is huge in size, I was looking for some other algorithm which will give a quicker result. Could you please suggest a better algorithm which will save me from using memcmp?
-- modified 26-Feb-16 8:46am.
|
|
|
|
|
Quote: Could you please suggest a better algorithm which will save me from using memcmp? Here it is:
struct xyz
{
BYTE byHex[16];
bool operator==(const xyz& other) const { return other.byHex == this->byHex; }
bool operator==(const BYTE buf[16]) const { return buf == this->byHex; }
};
But this won't be faster because the compiler will usually generate code that calls memcmp internally (or in most cases uses an inline version of memcmp ).
NOTE:
In my initial answer I forgot to make the functions const .
|
|
|
|
|
Hi Jochen,
First of all, many thanks for your solution. Although it has solved my operator == overloading question, but I have one more difficulty, may be a strange experience. The find algorithm of STL is not giving the iterator position, even if the item to be searched is located in the BYTE array. Does it have anything to do with the size of the arrays as well? because one BYTE array is of 16 bytes, and the one it is to be compared with is of 33 bytes? In such a case, how can I make the find algorithm give me the correct answer? Please help.
Thanks in advance.
- Sanjay
|
|
|
|
|
std::find is a function to search for an identical value of a specific type. If you have different types it won't work. This includes arrays of same type but different length.
What you are probably looking for is some kind of 'contains' (like strstr ) or 'begins with' (like memcmp and strncmp with length of searching value) function which you have to implement yourself.
Example:
for (int i = 0; i < m_vec.size(); i++)
{
if (MySearch(m_vec.at(i), searchValue))
{
break;
}
}
|
|
|
|
|
Visual Studio 2012, C++
I have several utilities to be put in a DLL.
If the utilities put in a DLL are built without MFC and without ATL, can they be used by those types of projects?
Can the products of multiple projects, within a single solution, be put into a single DLL? So far, my limited experience indicates this is not the case.
Can Visual Studio show the contents of a DLL? I don’t want a reverse compiler/assembler, I just want to see the signatures of the functions contained by the DLL.
My apologies for the double post. The first one disappeared and I thought I had messed up so posted again.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 25-Feb-16 19:12pm.
|
|
|
|
|
You can put any code into a DLL. It is even simpler and better when the DLL code did not use MFC or ATL (it can then be used by any application).
I'm not sure if I understand your second question. Do you mean to create a DLL with functions used by multiple applications where each application uses only a subset of exported functions?
If so, the answer is yes.
To list the symbols exported by a DLL you can use the DUMPBIN[^] command line tool (located in the VC\bin directory) with the /EXPORTS option.
You can also use the GUI tool Dependency Walker (depends.exe)[^].
Both will list the names of exported functions and variables. The Dependency Walker can also show the parameters when present in the DLL (has been build with C++ decoration).
|
|
|
|
|
Already answered in the ATL forum.
|
|
|
|