|
Force Code wrote: the bitmap is pasted with the dimensions most recently altered by user.
Probably a dumb question, but are you creating a new metafile created by drawing using the new
dimensions or editing an existing metafile when the user alters something?
Also, what do you mean by "the bitmap is pasted"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Mark Salsbery wrote: Probably a dumb question, but are you creating a new metafile created by drawing using the new
dimensions or editing an existing metafile when the user alters something?
Also, what do you mean by "the bitmap is pasted"?
OK, here's the scenario:
A user copies a bitmap from some source to the client area of this application. Then, in the client area, he resizes the bitmap by dragging an edge of it. Then he copies this resized bitmap (ctrl-c) and pastes it somewhere else in the client area (ctrl-v). Once he resized the image, the application converted it from a bitmap to a memory metafile. So, when it is copied with ctrl-c, it is copied as a metafile and then pasted as a metafile.
What I have done is just intercept the paste message right before the image (i.e. the meta file) is pasted. Then, for now, i.e. *strictly for testing purposes*, all I've done is make a duplicate of the clipboard data (i.e. the metafile), and replaced the clipboard data with this duplicate metafile. So basically NOTHING should be changed *AT ALL*. But when the image is pasted, its size has reverted to what it was before the user resized it.
Understand?
Maybe I should have asked to begin with - have you ever copied metafiles from the clipboard.
Here is the complete code I used to intercept the paste msg:
//following excerpt is from a subclassed WndProc in a DLL
//injected into an application's address space:
.
.
.
case CM_PASTE_WP: {
OpenClipboard(hwnd);
if (IsClipboardFormatAvailable(CF_ENHMETAFILE)) {
HENHMETAFILE henh = (HENHMETAFILE)GetClipboardData(CF_ENHMETAFILE);
int nSize = GetEnhMetaFileBits(henh,0,NULL);
BYTE* data = new BYTE[nSize];
GetEnhMetaFileBits(henh,nSize,data);
EmptyClipboard();
henh = SetEnhMetaFileBits(nSize,data);
SetClipboardData(CF_ENHMETAFILE,henh);
}
CloseClipboard();
}
break;
.
.
.
return CallWindowProc(r_obj->WordProcPrev,hwnd,message,wParam,lParam);
}
|
|
|
|
|
Force Code wrote: OK, here's the scenario
Thanks!
I don't see anything in THAT code that changes anything in the metafile.
It seems to me you may want to look in the "Once he resized the image, the application converted
it from a bitmap to a memory metafile" code and/or the PlayEnhMetaFile() code and make sure
everything is consistent with the DCs (resolution/units) and bounding rects.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
any chance the app is caching them ?
|
|
|
|
|
Chris Losinger wrote: any chance the app is caching them ?
Not entirely sure what you're implying.
The only state change in the process is that code snippet I supplied where I manipulate the clipboard. Comment that out, and everything is back to normal. The only conclusion I can reach is that what I'm putting back to the clipboard isn't really a copy. I've just been working with metafiles for the last couple of days.
|
|
|
|
|
Recently I try to convert mpg file to avi programmly, but it doesn't work , i am a beginner ,the code list below, anyone can give me suggestion? thanks.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
IBaseFilter *pSrcFilter = NULL;
hr = pGraph->AddSourceFilter(lpMpgFile, L"Source Filter", &pSrcFilter);
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void **)&pBuilder);
pBuilder->SetFiltergraph(pGraph);
hr = pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi, lpOutputAviFile, &pMux, NULL);
hr = pGraph->AddFilter(pMux, L"Mux Filter");
IBaseFilter *pMpeg2Splitter= NULL;
hr = CoCreateInstance(CLSID_MPEG2Demultiplexer, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pMpeg2Splitter);
hr = pGraph->AddFilter(pMpeg2Splitter, L"Mpeg2 Splitter");
IMpeg2Demultiplexer *pDemux = NULL;
hr = pMpeg2Splitter->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux);
AM_MEDIA_TYPE pMediaType;
memset(&pMediaType, 0x0, sizeof(pMediaType));
pMediaType.majortype = MEDIATYPE_Video;
pMediaType.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
pMediaType.formattype = FORMAT_MPEG2Video;
pMediaType.bFixedSizeSamples = FALSE;
pMediaType.bTemporalCompression = TRUE;
pMediaType.lSampleSize = 0;
MPEG2VIDEOINFO video_info;
memset(&video_info, 0x0, sizeof(MPEG2VIDEOINFO));
pMediaType.cbFormat = sizeof(MPEG2VIDEOINFO);
pMediaType.pbFormat = (BYTE *)&video_info;
AM_MEDIA_TYPE pMediaAudioType;
memset(&pMediaAudioType, 0x0, sizeof(pMediaAudioType));
pMediaAudioType.majortype = MEDIATYPE_Audio;
pMediaAudioType.subtype = MEDIASUBTYPE_MPEG1Payload;
pMediaAudioType.formattype = FORMAT_WaveFormatEx;
pMediaAudioType.bFixedSizeSamples = FALSE;
pMediaAudioType.bTemporalCompression = FALSE;
pMediaAudioType.lSampleSize = 0;
MPEG1WAVEFORMAT audio_info;
memset(&audio_info, 0x0, sizeof(MPEG1WAVEFORMAT));
pMediaAudioType.cbFormat = sizeof(MPEG1WAVEFORMAT);
pMediaAudioType.pbFormat = (BYTE *)&audio_info;
IPin *pPin0 = NULL;
hr = pDemux->CreateOutputPin(&pMediaType, L"Video Output", &pPin0);
IMPEG2StreamIdMap *pStreamIdMap = NULL;
hr = pPin0->QueryInterface(IID_IMPEG2StreamIdMap, (void **)&pStreamIdMap);
hr = pStreamIdMap->MapStreamId(0xC0, MPEG2_PROGRAM_ELEMENTARY_STREAM, 0, 0);
IPin *pPin1 = NULL;
hr = pDemux->CreateOutputPin(&pMediaAudioType, L"Audio Output", &pPin1);
IMPEG2StreamIdMap *pStreamIdMap1 = NULL;
hr = pPin1->QueryInterface(IID_IMPEG2StreamIdMap, (void **)&pStreamIdMap1);
hr = pStreamIdMap1->MapStreamId(0xE0, MPEG2_PROGRAM_ELEMENTARY_STREAM, 0, 0);
//error occurs in below code
hr = pBuilder->RenderStream(NULL, NULL, pSrcFilter, NULL, pMpeg2Splitter);
hr = pBuilder->RenderStream(NULL, NULL, pMpeg2Splitter, NULL, pMux);
hr = pBuilder->RenderStream(NULL, NULL, pMpeg2Splitter, NULL, pMux);
.......
|
|
|
|
|
why doen't it work ?
what error do you get ?
|
|
|
|
|
A few potential problems...
SetOutputFileName() adds the AVI mux filter to the graph - you don't need to add it manually.
I'm not sure why you're using the MPEG2 splitter AND muxer.
Regardless, you'll need an mpeg2 decoder for it to work (I don't think there's one included with
Windows).
I would try simplifying your graph building first. Compare your method to the method shown here:
Building the Recompression Graph[^]
Also testing it in graphedit.exe can help to make sure you're using the correct filters.
MArk
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Thanks you very much! I get the root of problem by using graphedit.exe: the input mpg file is a mpeg-1 file, so the file source filer outputs mpeg1-stream, but mpeg2demultiplexer requires mpeg2-stream, when it's running, it popup many DCDSPFilter.ax window and show a error message: These filters cannot agree on a connection, verify type compatibility of input pin and output pin. after I change the mpeg2demultiplexer to mpeg1streamsplitter and add the mpeg1 decoder, it runs OK.
But this remains a problem: how can I get the type of mpeg file? I have to identify the file type(mpeg1 or mpeg2) programmly so that I can add the according filter. ???
|
|
|
|
|
liur17 wrote: how can I get the type of mpeg file? I have to identify the file type(mpeg1 or mpeg2) programmly
so that I can add the according filter. ???
2 possible ways I can think of:
1) After the successful AddSourceFilter() call, obtain a IFileSourceFilter interface from the
source filter and use the IFileSourceFilter::GetCurFile() method to get the media type (looking
for MPEG subtypes).
2) Let intelligent connect insert the necessary filters for you.
Use AddSourceFilter() and SetOutputFileName() like you're doing, add the compressor filter you
want for the destination AVI file, and use RenderStream() to connect the filters added by
AddSourceFilter() and SetOutputFileName(), with the intermediate compressor filter.
If you have suitable MPEG filters installed, intelligent connect will insert them for you.
If not, RenderStream() will fail.
A second call to RenderStream() will connect an audio stream to the AVI muxer if it's available
(again, see here[^] for an example.
You can try this in graphedit by manually adding a filesource async filter, setting the input
filename, add a filewriter filter, set the output filename, add an AVI Mux filter, and connect
the filesource to the filewriter filter.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
I got it. Thank you for your kind reply.
|
|
|
|
|
|
1. For UI Localization: Is is possible to have VC++.Net 2003 application with resources in .rc file for one language (English) and resouce only dll for another language (Japanese)?
2. What modification in code required to handle the switching between .rc and dll resources @ runtime to display the appropriate UI resources in the corresponding language? (either after changing the locale of the English OS or running the application on Japanese OS)?
Thanks & Regards,
Neeraj
|
|
|
|
|
Hi all,
Part of the app I'm developing downloads fairly large files via HTTP. Everything works great, except for when the clients network connection is dropped. I have tried using WSAGetLastError, but it always returns 0. The thread just keeps pulling mystical data, then it just stops after about 300 or so KB. No crash or anything.
do
{
len = recv( Socket, buffer, sizeof( buffer ), 0 );
if( ( pos + len ) > contentLength )
return 0;
memcpy( body + pos, buffer, len );
pos += len;
int error = WSAGetLastError( );
if( error )
return 0;
} while( len > 0 );
To simulate a network drop I am turning my modem off.
Has anyone got a solution to this?
|
|
|
|
|
Silly me. I just realised that the socket was blocking.
I set it to non-blocking and it works fine.
|
|
|
|
|
<br />
class Foo<br />
{<br />
private:<br />
int (*pf)(int);<br />
<br />
public:<br />
Foo()<br />
{<br />
this->pf = &Foo::cube;
}<br />
<br />
private:<br />
int cube(int n) {return n*n*n;}<br />
<br />
};<br />
how do i get that statement in the constructor working? any help is greatly appreciated.
|
|
|
|
|
eirche wrote: int (*pf)(int);
Should make this a member function pointer. So it should be...
int (<code>Foo::</code>*pf)(int);
|
|
|
|
|
thank you for the quick response. it's working like a charm.
|
|
|
|
|
set the cube() member function either static or global...
|
|
|
|
|
hi all
I use in my program WaitForMultipleObjects function for chake if some process that I use stop or not, but If some ot the programs made mistake this funtion dont returns.
how I can chake my programs are runing or thay stoped?
|
|
|
|
|
can you please write a proper english ?
i can't get a word of what you're saying...
|
|
|
|
|
|
david bagaturia wrote: how I can chake my programs are runing or thay stoped?
Programatically:
When you create the process, store the handler. You can then later check handler after handler if the process is still running.
Physically:
Hit Ctrl+Shift+Esc, go to process tab, and check if your processes are still alive.
|
|
|
|
|
Perhaps something like this:
bool HasProcessExited(HANDLE hProcess)
{
return WaitForSingleObject(hProcess, 0)==WAIT_OBJECT_0;
}
Steve
|
|
|
|
|
Could you please tell , what type of handles are you using for WaitForMultipleObject()?
AJay
|
|
|
|
|