|
Hi there,
The image data that i have got represent intensity of light falling on the sensor(whcih is 32 bits per pixel) . Can u pls suggest me how i can use palette files when displaying images to visualise contrast in intensities?
Many Thanks
|
|
|
|
|
Never worked with palettes so i can't, sorry...
> 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. <
|
|
|
|
|
Currently your data is in long integer right.
So now just ur data is actualy a pixel data. which contains the pixel intensity for Monochrome and RGB for color.
So use GDI+
You want pixel data as long pointer array to bitmap from which it will be easy to create a image.
Bitmap * BitMapHandler::PixelInfo2BitMap(int width, int height,
int *pixData )
{
// Fistly create a temp Bmp with the height and width of the image.
Bitmap bit(width, height, PixelFormat32bppARGB );
// Create clone as as to return as output.
Bitmap *bmp = bit.Clone(0, 0, bit.GetWidth(), bit.GetHeight(),
PixelFormat32bppARGB);
BitmapData bmData;
Rect rect(0, 0, bmp->GetWidth(), bmp->GetHeight());
bmp->LockBits(rect,
ImageLockModeRead | ImageLockModeWrite,
PixelFormat32bppARGB,
&bmData);
int stride = bmData.Stride;
BYTE *pArr = (BYTE *)((void *)bmData.Scan0);
int nOffset = stride - width*4;
int pixel;
for(int y=0; y < height;y++) {
for(int x=0; x < width; ++x ) {
// GDI lies about RGB - internally it's BGR
pixel = pixData[y*width+x];
pArr[3] = (BYTE) ((pixel >> 24) & 0xff); // alpha
pArr[2] = (BYTE) ((pixel >> 16) & 0xff); // pixel red
pArr[1] = (BYTE) ((pixel >> 8 ) & 0xff); // pixel green
pArr[0] = (BYTE) ((pixel ) & 0xff); // pixel blue
pArr += 4;
}
pArr += nOffset;
}
bmp->UnlockBits(&bmData);
return (bmp);
}
Hope it is enough
|
|
|
|
|
Hi ARJ,
Thnaks for your code.Actually,the code throws an exception at
Bitmap *bmp = bit.Clone(0, 0, bit.GetWidth(), bit.GetHeight(),PixelFormat32bppARGB);
in getting the values of widht and height in GdiPlusBitmap.h
The exception is
Unhandled exception at 0x00411bc1 in test.exe: 0xC0000005: Access violation reading location 0x00000004.
I am not sure why it occurs. Could you please advice me on this?
|
|
|
|
|
Hello,
I am trying to capture a window from an external App Example Calculator.
I am able to get the handle of the window. If the user opens a second instance, I am able to get that handle too using EnumWindows.
Which means I have 2 handles for the 2 calculators. Short of using the Handle is there anything else that I could use to differenciate the 2 windows. I can't use the window title since they are both the same.
Reason for asking:
I know the handle gets reused, but is it possible for the handle to change after the window has been created or does it stay the same after creation? Yes, if I close the window, I know I will not get the same handle.
Is it possible that If the user minimizes the window and activates it again, we get a new handle?
If the handle changes during the lifetime of the window whats the best way of keeping track of that window?
I have created a thread and am using the same function to handle capturing data from the 2 windows by passing the handle as a parameter. However, I can only get the data from one of the windows, or am I better off creating multiple threads which is what I was avoiding?
Could someone please help.
|
|
|
|
|
FISH786 wrote: but is it possible for the handle to change after the window has been created or does it stay the same after creation
AFAIK, a window handle doesn't change over the lifetime of a window.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks again.
which is what I thought but wanted to be sure.
I guess back to debugging and find out why I can't get the data from the second window.
However, I should be able to use the same thread and pass the handle as a parameter? or am I better off creating multiple threads and dedicate each thread to a window for the lifetime of that particular window?
|
|
|
|
|
What is the reason of error message:
error C2036: 'void *' : unknown size
This was a result of compilation of such a code snippet:
void ** c=malloc(20);
int i=1;
c[i] = c[i-1]+1;
(Forget uninitialized block of memory c )
I'd expect that size of any pointer is known.
|
|
|
|
|
The pointer points to something which is not known (otherwise, you would have used int* for instance). Thus, when you are accessing it as an array, the compiler doesn't know how much offset he has to apply to the address to access the following element (because he doesn't know the size of an element). If you want to manipulate bytes, I suggest that you use an array of unsigned char instead.
|
|
|
|
|
I dont think it is a good practice to allocate a viod pointer. Void pointer is not introduded so as to allocate and use, rather its use is in holding data. Since Void can hold any type of data. You cannot able to allocate the exact length. Thats why complier doesnot allow you to do so.
So it better to allocate for some data types.
|
|
|
|
|
c[i-1] is a void *
c[i-1] + 1 you're trying to increment to the next "void" object, but void has no size
change the line of code
void** c = malloc(20)
to
int** c = malloc(20)
and you'll see that it compiles.
|
|
|
|
|
liquid_ wrote: I'd expect that size of any pointer is known.
This is true.
Size of a pointer is 32 bits in 32-bit Windows and 64 bits in 64-bit Windows.
But the error talks about something else.
Consider this example.
int* i = 10;
This uses 4 bytes to store the value 10
char* c = 10;
This uses 1 byte to store the value 10
This is what the above error talks about.
So if you do
void* v = 10;
you should get this error since the compiler is not able to get the size needed.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi,
I am making my application unicode supporting one.. i face the following problem..
If i copy a unicode content and paste it in the edit box by ctrl+v operation, its pasting some junk values.. whereas if i give rightclick(mouse)+paste, its copying fine...
Later, i came to know that windows clipboard doesnt support unicode characters..
I use windows xp now...
Does anyone have any idea on how to overcome this problem..
Thanks,
Rakesh
|
|
|
|
|
Rakesh5 wrote: Later, i came to know that windows clipboard doesnt support unicode characters..
You came to know WRONG. (Unless you knew that pre-1994)
From the docs: (http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx[^])
CF_TEXT Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
CF_UNICODETEXT Windows NT/2000/XP: Unicode text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.
I hope that makes things simpler for you!
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Thanks a ton Iain clarke...
It worked fine...
Thanks once again..
Rakesh
|
|
|
|
|
|
Hi Experts,
I have created an Database application using CDatabase and CRecordset.
Following is some part of code where the Exception occurs....
CRecordset UserRs(&UserCn);
.
.
Sql="Select * from UserInfo";
UserRs.Open(CRecordset::snapshot,Sql,CRecordset::none);
The Exception is :
"Attempt to open a table failed-there were no columns to retrieve were specified.."
I m confused..Becoz the same code run on my machine doesnt work on
others machine.
and the query also correct.
plz Help me..
Waitng for ur Reply..
I have never failed,I just found 1000 ways that never works.
Regards,
Victory.
|
|
|
|
|
Assuming that there is a table in your DB called UserInfo, I would check that the CDatabase object is connected to the datasource using UserCn.IsOpen before trying to open the RS.
Check that the datasource is configured the same on the target machine as it is on yours - including permissions. In my experience, that is the most common source of this type of problem... though I admit my needs have never occasioned use of C++ for database connectivity.
MZR
|
|
|
|
|
Hi All,
I'm having real difficulty in getting transparency to work in my application. I am drawing an image into the window title bar, the code (in short) is below:
void CThemedDialog::OnNcPaint()
{
CDC* pWindowDC = GetWindowDC();
CRect rcWindow;
GetWindowRect(rcWindow);
m_bitmapWindowIcon.Draw(pWindowDC->GetSafeHdc(), 5, 5);
ReleaseDC(pWindowDC);
m_bitmapWindowIcon is an ATL::CImage object that is loaded from a png file (I've also tried with a jpeg file). I never get any transparency - just white pixels where the transparent ones should be. Is there something stupid I am doing? I'm pulling my hair out over this!
Thanks in advance,
Dave
|
|
|
|
|
Please clear you question
|
|
|
|
|
in a textbox i have "Sam james thomas" which is 3 names
can anyone write a code that will only take the middle name in C++
thanks
|
|
|
|
|
Um, yep. Pretty much anyone can do it.
|
|
|
|
|
You can use of CString::Mid.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
thats a real basic homework:
1. find the 2 blank positions
2. extract the chars in between
it is no question it is a sign thats you arent engaged enough for writing code
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Tiyani Miyambo wrote: "Sam james thomas"
strtok(strtok("Sam james thomas", " "), null);
|
|
|
|