|
Unfortunately the only answer is to create your own layout manager, that checks the dimensions and DPI of the screen on start up, and adjusts each control to fit.
Use the best guess
|
|
|
|
|
I'm trying to display an image from a stream data.
But there is no image when getting image::from stream.
It's my source code:
IStream* pstream = NULL;
if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream)))
{
ULONG lreal = 0;
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );
if(pstream!= NULL)
{
MessageBox(hWnd,
" Stream is OK",
"Connection strt",
MB_ICONINFORMATION|MB_OK);
}
Image* image =Image::FromStream(pstream);
if(image)
{
RECT rect;
::GetWindowRect(hWnd, &rect);
Graphics graphics(hWnd);
graphics.DrawImage(image, 0, 0, rect.right-rect.left, rect.bottom-rect.top);
}
else
{
MessageBox(hWnd,
"No image is written",
"Connection strt",
MB_ICONINFORMATION|MB_OK);
}
if(image)
delete image;
image = NULL;
if(pstream)
pstream->Release();
pstream = NULL;
}
There is no image from data. Can anyone help me in this?
Thanks!
|
|
|
|
|
I have never tried doing it this way, but it looks like you took the sample from here[^], removed some stuff to make it simpler and changed it to write directly to your generic IStream object. I am not sure I like the whole thing, but it is kind of an interesting approach - if it works.
You do not show how you acquire the data that is stored in chIncomingDataBuffer . Are you sure this buffer contains an entire image?
I don't know if it is going to work, but right after you write the data to your pstream , its internal position will be pointing to the end of the data you just wrote. Try calling Seek() in order to change it to point to the start of the data.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
I checked for an image of a particular data bytes then read it and wrote the code like this..
int iff2 = 2970;
iBufferLength = iSpaceRemaining = sizeof(chIncomingDataBuffer);
iEnd = 0;
iSpaceRemaining -= iEnd;
iBytesRead = recv(Socket, chIncomingDataBuffer+iEnd, iSpaceRemaining, 0);
iEnd+=iBytesRead;
if(iEnd ==iff2)
{
MessageBox(hWnd,
"Image is written ok",
"Connection strt",
MB_ICONINFORMATION|MB_OK);
IStream* pstream = NULL;
In starting if I'm trying to write an image using fwrite then its ok with exact bytes data.
But on stream, its showing some data in stream but not loading any image.
|
|
|
|
|
Ok. Let me know what happens when you call Seek() on pstream after writing the data.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
I added code for Seek() method but problem is same.
ULONG lreal = 0;
LARGE_INTEGER liBegining = { 0 };
if(S_OK && pstream)
{
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );
pstream->Seek(liBegining, STREAM_SEEK_SET, NULL);
this is the added code.
But there is nothing.
|
|
|
|
|
Wait a second. I see that you changed the code. You have a bug in if(S_OK && pstream) . The value of S_OK is zero, so in the code above you are not not going to do the Write() and the Seek() .
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Yes i also get this., S_OK is zero.
But If I'm removing this then pstream is having some value.
Is there any problem with CreateStreamOnHGlobal()?
and one more thing,, as I got I can't draw anything outside paint event
if I'm limited to GDI+.
|
|
|
|
|
It seems this is not an easy fix, so let me ask you a couple of things.
- Do you have to use the Image and Graphics stuff?
- What is the format of your images (BMP, JPG, etc.)?
- Are you going to be drawing anything on top of your image?
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
-I'll have to recv some data on winsock socket and then display that on screen.
I'm using Image and Graphics it for ease.
-Its BMP
-No nothing on top of my image.
-> I'll have to recv the bytes and display image data on screen without saving it first.
|
|
|
|
|
Good, I figured it was something like this - there are so many classes and tools that need to load the images from file in order to display them, but you have to search hard to find some that will let you load an image already in memory.
Take a look at this article: Simple class for drawing pictures (JPG, TIFF, GIF, etc...)[^]
Examine the code to figure out what is wrong with your code or just use the class in your project. I know it is old and there might be newer stuff out there, but I have used the class to perform similar tasks. I have a project where I am using a button class derived from this class and it makes it possible to display just about any image on the buttons.
It has been so long since I looked at the code, that I did not remember it uses a similar approach as you did with the IStream object, so I am sorry I brought that into question.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
|
Ahhh, I see. Sorry if I stepped on your toes, I should have checked for something like that.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
SoMad wrote: Sorry if I stepped on your toes You didn't; I just thought some background detail may be useful.
Use the best guess
|
|
|
|
|
You also posted this question at Display image from stream[^]. Please do not post the same question in multiple forums.
Use the best guess
|
|
|
|
|
Yeah Sorry for posting at two places.
But the code that was to be implemented is not returning an image, as I implemented that in my code.
So I just wrote it as a new question instead revising the old one.
Thanks!
|
|
|
|
|
toms from newdelhi wrote: So I just wrote it as a new question instead revising the old one. On the contrary, you posted the same question in this forum and in Q&A. Common sense should tell you that is the wrong thing to do, but if you still don't understand then read http://www.codeproject.com/Messages/2922875/HOW-TO-ASK-A-QUESTION.aspx[^], especially point 1.
Use the best guess
|
|
|
|
|
Hi
I'm new in DirectShow programming, and after more than week of reading a lot and trying to understand some of the concepts, without a luck I'm asking my question:
I used the filter EZRGB24 from Microsoft SDK and changed it according to my need and checked it out with graphedit to see it works.
Now I need to use this filter in my code.
1. How can I use some filters in row?
2. Can I use the buffers of the last filter in my code? I don't need to save the stream or display it.
Thank you,
Moshiko
|
|
|
|
|
How to build 64 bit application on visual studio 2003?
|
|
|
|
|
|
VS 2003 does not support the 64-bit compiler out of the box.
You can however, install the latest Microsoft SDK and use the 64-bit compiler that comes along with it.
But it is recommended to go for VS2005, which supports building 64-bit applications out of the box.
|
|
|
|
|
Thank you Superman for valuable information.
|
|
|
|
|
Hello ,
I am Lakshmanan, a new to MFC.
I have created a multilanguage supported application in mfc.
The below problem occurs in SImplfied and Traditional Chineese localization only
I Have created a dialog having Textbox, buttons , radiobutton and check boxes.
When Displaying the dialog box for the first time, the text inside the button control is not visible fully.
Alignment set in the button control property is Default.
But, on closing the dialog box and opening it again causes the text to be visible clearly and fully.
Also, if the check box state is changed (From Checked to Unchecked), the text inside button is clearly and fully visible.
Also on tab change, (means getting focus to button), the text inside button is getting clearly and fully visible.
Anyone please help me to sort out the problem.
Thanks in advance.
Regards,
Lakshmanan
|
|
|
|
|
I didnot know what happen. Does you project set as Unicode. Or you system have the suitable Chinese Font?
If you can get screen image, perhaps I can help you.
|
|
|
|
|
Hello Mr. yu-jian,
Thanks for your Quick reply.
The Project is Set to Multibyte Character Set.
I have Installed Language Packs for chinese (both traditional and simplified)
Thanks
Lakshmanan
|
|
|
|