|
Hi,
are you sure it is 2147467259 and not -2147467259 ???
that one equals 0x80004005 which is simply good old E_FAIL
GDI+ is very good at error handling, everything is called "general error" and
the error number does not tell anything.
In your case you are running out of memory.
Didn't they tell you you should Dispose of all objects you no longer need when
such objects are instances of a class that offers a void Dispose() method ?
You are polluting your entire system!
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: In your case you are running out of memory.
Didn't they tell you you should Dispose of all objects you no longer need when
such objects are instances of a class that offers a void Dispose() method ?
I guess I am naive to think that C# garbage collection would "just work". More likely this is my problem for using GDI+ within C#. So the challenge for me remains to either:
a) Reuse a single instance of myBitmap.
b) Invoke the Dispose() method so too many objects don't overrun the heap.
I'm not sure I know how to do either, but will try.
|
|
|
|
|
Getting a mysterious error message is a good indication naivety has to be scaled back.
Invoking a method with no parameters and no return value is rather easy, reusing a
Bitmap does not sound like a good idea.
ss42a wrote: I'm not sure I know how
Then that's why they invented "documentation", available under either MSDN or Google.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
The next likely cause for a GDI+ general error is a bad image file.
Suggestion: log the files one by one before creating the new Bitmap and/or
show the filename in the catch construct.
The (last) one shown is the suspicious one; try loading just that one; or try
double-clicking it.
BTW: IIRC GDI+ can't handle 1-bit-per-pixel images.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you!
It turns out that some JPEG image files; which look fine as thumnails, display correctly; may have some kind of defect that causes GDI+ to throw an error. This is good, since I'm using the try/catch blocks to isolate them. Thank you for your help.
Below is the modified code which works fine; but coughs up an occasional image file that may look fine, but has some internal defect that confuses the GDI+ decoder.
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Drawing;<br />
<br />
<br />
namespace ListFiles1<br />
{<br />
class Program<br />
{<br />
<br />
static void Main(string[] args)<br />
{<br />
<br />
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"c:\image");<br />
<br />
foreach (System.IO.FileInfo file in dir.GetFiles("*.jpg"))<br />
{<br />
<br />
try<br />
{<br />
Bitmap myBitmap = new Bitmap(file.FullName);<br />
Console.WriteLine("{0}, {1}, {2}, {3}", file.Name, file.Length, myBitmap.Width, myBitmap.Height);<br />
myBitmap.Dispose();<br />
}<br />
catch (Exception e)<br />
{<br />
Console.WriteLine("*************** Exception Caught for {0}", file.FullName);<br />
Console.WriteLine(e.Message);<br />
}<br />
<br />
}<br />
Console.WriteLine("Any character to exit...");<br />
Console.ReadLine();<br />
}<br />
}<br />
}<br />
<br />
|
|
|
|
|
Hi there!
Is there any way to figure out the video file width and heigth before loading it using vmr9 or other filters?
Thanks in advance,
Andrew
|
|
|
|
|
Hi
you want the video width height through a filter wether vmr9 or any othr,then note that a Directhow Filter only returns the data when it will receive a MediaSample.
|
|
|
|
|
Hello,
I'm using C++ Builder 2007 prof. from Borland. I will make my own icon's but I can't find my Image Editor. Can sombody help my were I find them. It's not on the CD or. I have the program full instalt.
Jelle.
|
|
|
|
|
While there may be some Builder users here, this is a Visual C++ board,
so you may also want to ask on a Borland-centric board as well
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
can any one help me to solve this problem i am a new leaener to direct show.
i have created custom filetrs and pins and connected them but why it is not able to play the file.
After compiling its not giving any error and running successiflly. but it is not rendering. can any one help me..
here is the code.
/*
BuildingFilter.cpp
This program is to create our own filters
*/
#include <DShow.h>
#include <InitGuid.h>
#include <dmo.h>
//#include <dmoimpl.h>
#include <dmodshow.h>
//audio filters defined
#define INITGUID // have to define this so next line actually creates GUID structure
DEFINE_GUID(CLSID_WmAudioDecoderDmo,0x2eeb4adf, 0x4578, 0x4d10, 0xbc, 0xa7, 0xbb, 0x95, 0x5f, 0x56, 0x32, 0x0a);
DEFINE_GUID(IID_IDMOWrapperFilter,0x52d6f586,0x9f0f,0x4824,0x8f,0xc8,0xe3,0x2c,0xa0,0x49,0x30,0xc2);
//DEFINE_GUID(CLSID_WmAudioDecoderDmo,0x874131cb, 0x4ecc, 0x443b, 0x89, 0x48, 0x74, 0x6b, 0x89, 0x59, 0x5d, 0x20);
DEFINE_GUID(CLSID_WMVVideoDecoder, 0x4A69B442, 0x28BE, 0x4991, 0x96,0x9C, 0xB5, 0x00, 0xAD, 0xF5, 0xD8, 0xA8);
//DEFINE_GUID(CLSID_WmVideoDecoderDmo,0x82d353df, 0x90BD, 0x4382, 0x8b, 0xc2, 0x3f, 0x61, 0x92, 0xB7, 0x6e, 0x34);
void main(void)
{
IGraphBuilder* g_pGraphBuilder = NULL; // assume graph builder already created
IBaseFilter* g_pSource = NULL; //source filter
IBaseFilter* g_pVideoRender = NULL; //video render
IBaseFilter* g_pAudioRender = NULL; //sound render
IFileSourceFilter* pFileSourceInt = NULL;
IBaseFilter *pDmoFilter = NULL;
IBaseFilter *pDmoFilterV = NULL;
IDMOWrapperFilter *g_pAudioParser;
IDMOWrapperFilter *g_pVideoParser;
HRESULT hr;
IMediaControl *gControl = NULL;
IMediaEvent *gEvent = NULL;
IEnumPins* EnumPins = NULL;
IPin* OutPin = NULL;
IPin* InPin = NULL;
ULONG fetched;
PIN_INFO pinfo, pinfoVideoParser, pinfoVideoParserOut, pinfoVideoRenderer;
IEnumPins* EnumPinsV = NULL;
IPin* OutPinV = NULL;
IPin* InPinV = NULL;
ULONG fetchedV;
PIN_INFO pinfoV;
long evCode=10;
CoInitialize(NULL);
CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void **)&g_pGraphBuilder);
hr = g_pGraphBuilder->QueryInterface(IID_IMediaControl, (void **)&gControl);
hr = g_pGraphBuilder->QueryInterface(IID_IMediaEvent, (void **)&gEvent);
CoCreateInstance(CLSID_WMAsfReader, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pSource);
//CoCreateInstance(CLSID_WmAudioDecoderDmo, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pAudioParser);
//CoCreateInstance(CLSID_WmVideoDecoderDmo, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pVideoParser);
CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pAudioRender);
CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pVideoRender);
// Create the DMO audio Wrapper filter.
hr = CoCreateInstance(CLSID_DMOWrapperFilter, NULL, CLSCTX_INPROC, IID_IBaseFilter, reinterpret_cast<void**>(&pDmoFilter));
pDmoFilter->QueryInterface(IID_IDMOWrapperFilter, (void **)&g_pAudioParser);
g_pAudioParser->Init(CLSID_WmAudioDecoderDmo, DMOCATEGORY_AUDIO_DECODER);
g_pAudioParser->Release();
//add DMO audio filter to the filter graph.
g_pGraphBuilder->AddFilter(g_pSource,NULL);
g_pGraphBuilder->AddFilter(pDmoFilter ,L"Audio transfer");
// Create the DMO video Wrapper filter.
hr = CoCreateInstance(CLSID_DMOWrapperFilter, NULL, CLSCTX_INPROC, IID_IBaseFilter, reinterpret_cast<void**>(&pDmoFilterV));
pDmoFilterV->QueryInterface(IID_IDMOWrapperFilter, (void **)&g_pVideoParser);
g_pVideoParser->Init(CLSID_WmAudioDecoderDmo, DMOCATEGORY_VIDEO_DECODER);
g_pVideoParser->Release();
//add the DMO video wrapper filter.
g_pGraphBuilder->AddFilter(pDmoFilterV ,L"Video transfer");
// g_pGraphBuilder->AddFilter(g_pVideoParser, NULL);
g_pGraphBuilder->AddFilter(g_pAudioRender,NULL);
g_pGraphBuilder->AddFilter(g_pVideoRender,NULL);
hr = g_pSource->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSourceInt);
hr = pFileSourceInt->Load(L"C:\\Documents and Settings\\amiyakumar.d\\My Documents\\Jog_Top-Down_View\\video.wmv",NULL);
if( hr == E_FAIL)
printf("\n Failed to open the file\n");
// find 2 source output pins
g_pSource->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &OutPin, &fetched); //1 pins for source audio
OutPin->QueryPinInfo(&pinfo);
EnumPins->Next(1, &OutPinV, &fetched); //1 pins for source video
OutPinV->QueryPinInfo(&pinfoV);
/*
// find audio parser input
pDmoFilter->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &InPin, &fetched);
InPin->QueryPinInfo(&pinfo);
pinfo.pFilter->Release();
if(pinfo.dir == PINDIR_OUTPUT)
{
InPin->Release();
EnumPins->Next(1, &InPin, &fetched);
}
//connect
g_pGraphBuilder->Connect(OutPin, InPin);
InPin->Release();
OutPin->Release();
//pinfo.pFilter->Release(); // make sure you release the returned IBaseFilter interface
//pinfoV.pFilter->Release();
if (pinfo.dir == PINDIR_INPUT) // check if we have wrong pin (not input pin)
{
OutPin->Release();
EnumPins->Next(1, &OutPin, &fetched); // if so, get next pin
}
EnumPins->Release();
// find audio parser output
pDmoFilter->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &OutPin, &fetched);
InPin->QueryPinInfo(&pinfo);
pinfo.pFilter->Release();
if (pinfo.dir == PINDIR_INPUT)
{
OutPin->Release();
EnumPins->Next(1, &OutPin, &fetched);
InPin->QueryPinInfo(&pinfo);
}
EnumPins->Release();
// find audio render input
g_pAudioRender->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &InPin, &fetched);
InPin->QueryPinInfo(&pinfo);
pinfo.pFilter->Release();
if(pinfo.dir == PINDIR_OUTPUT)
{
InPin->Release();
EnumPins->Next(1, &InPin, &fetched);
}
// connect
g_pGraphBuilder->Connect(OutPin, InPin);
InPin->Release();
OutPin->Release();
*/
// find video parser input
pDmoFilterV->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &InPinV, &fetchedV);
InPinV->QueryPinInfo(&pinfoVideoParser);
//pinfoVideoParser.pFilter->Release();
/*
if(pinfoVideoParser.dir == PINDIR_OUTPUT)
{
InPinV->Release();
EnumPins->Next(1, &InPinV, &fetchedV);
}
*/
// connect
g_pGraphBuilder->Connect(OutPinV, InPinV);
//InPinV->Release();
//OutPin->Release();
// find video parser output
pDmoFilterV->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &OutPinV, &fetchedV);
OutPinV->QueryPinInfo(&pinfoVideoParserOut);
while(pinfoVideoParserOut.dir == PINDIR_INPUT)
{
EnumPins->Next(1, &OutPinV, &fetchedV);
OutPinV->QueryPinInfo(&pinfoVideoParserOut);
}
//pinfoVideoParserOut.pFilter->Release();
// find video render input
g_pVideoRender->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &InPinV, &fetchedV);
InPinV->QueryPinInfo(&pinfoVideoRenderer);
//pinfoVideoRenderer.pFilter->Release();
/*
if(pinfoVideoRenderer.dir == PINDIR_OUTPUT)
{
InPinV->Release();
EnumPinsV->Next(1, &InPinV, &fetchedV);
}
*/
// connect
g_pGraphBuilder->Connect(OutPinV, InPinV);
//InPinV->Release();
//OutPinV->Release();
// hr = g_pGraphBuilder->QueryInterface(IID_IMediaControl, (void **)&gControl);
// hr = g_pGraphBuilder->QueryInterface(IID_IMediaEvent, (void **)&gEvent);
hr = gControl->Run();
gEvent->WaitForCompletion(INFINITE, &evCode);
hr = gControl->Stop();
gControl->Release();
gEvent->Release();
pFileSourceInt->Release();
g_pAudioRender->Release();
// g_pVideoRender->Release();
// g_pAudioParser->Release();
// g_pVideoParser->Release();
g_pSource->Release();
g_pGraphBuilder->Release();
CoUninitialize();
}
amiya kumar das
|
|
|
|
|
Hello,
I wonder if anyone out there has some experience in using color management with GDI+?
Specifically, when retrieving pixels from a GDI+ Bitmap using the LockBits/UnlockBits methods with a BitmapData object, should I assume that the RGB values in the BitmapData scan0 buffer are in linear light RGB space or gamma corrected RGB space? If gamma corrected, what white point/specific RGB space is used? Does it depend on how the Bitmap was constructed? Here are specific situations I need to know about:
- If a GDI+ Bitmap is constructed using one of the methods that indicates embedded color management will be used, such as Bitmap::Bitmap(const WCHAR *filename,BOOL useIcm), how does that Bitmap apply color correction when useIcm is set to TRUE? Does it hand me gamma corrected RGB values in the BitmapData scan0 buffer, or linear light RGB values? What does it hand me if useIcm is set to FALSE?
- If I later pass new data to the Bitmap above (constructed with useIcm = TRUE), using my own buffer and the ImageLockModeUserInputBuf flag, do I have to do my own gamma correction? That is, will the Bitmap object assume my data is linear RGB or gamma corrected RGB?
- If I then draw the Bitmap to the screen or to a printer with a Graphics object constructed using Graphics::Graphics(HWND hwnd, BOOL icm), with icm set to TRUE, does the Graphics object expect the data in the Bitmap object to be gamma corrected or linear RGB? With what white point? Does it depend on how the Bitmap was constructed? What if the Graphics object was created with icm set to FALSE? What if either the Bitmap or the Graphics object uses ICM, and the other doesn't?
- If I now use one of the Graphics::DrawImage methods with an ImageAttributes object, is the RGB data in the Bitmap object assumed to be in linear RGB? How do all these things interact?
Excuse me if there is already documentation on this somewhere, but I have been unable to find it. I would very much like to know if there is some comprehensive documentation somewhere about how GDI+ uses ICM.
Any information would be appreciated, but especially on the topic of what to do when passing my own pixel buffer to a Bitmap object using a BitmapData object with the ImageLockModeUserInputBuf flag set. Do I have to do all the color management on the data myself in that case? Or would that cause problems because the Bitmap expects to do that itself?
Thanks for any help you can give.
|
|
|
|
|
plz can someone help me to get a FREE version of infragistics NetAdbantage for .Net from onother source of "www.infragistics.com" ?
|
|
|
|
|
Hi how do create fonts in font lab. Are there a step by step instructions I can follow?
|
|
|
|
|
I have no idea where you got the idea that this site supports FontLab. Try a better source of information on it, like this[^].
|
|
|
|
|
|
Mark Salsbery wrote: CodeProject - Your Visual Studio and .NET Resource - and Typography?
CodeProject Atlas -- Supporting the world since 2007
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I'm experimenting with DirectX but am having trouble finding free software to create model(.x) files.
If anyone knows of any good free software (yes i'm a poor student, so I can't afford professional stuff) I'd love to know about it.
I do have access to Solidworks (2006 SP4.1), none of the lecturers round here seem to know if you can make .x files with it?
Can anyone help me?
Mark.
|
|
|
|
|
MarkBrock wrote: I'm experimenting with DirectX but am having trouble finding free software to create model(.x) files.
http://www.blender.org/features-gallery/features/[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Thanks heaps!
that's exactly what I've been looking for .
Mark.
|
|
|
|
|
MarkBrock wrote: that's exactly what I've been looking for
Its a good product, but it is not alone, so if you find something it can't do, ask. There are about half a dozen free modelers of various quality, more so than half a dozen in the low quality area (or too young to know). There are translators, and various processing/modifiers to do things blender does not.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
This[^] might help.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for the link Pete, the software looks really good.
Anything that is easier to use than Blender will make me a very happy man at the moment .
Mark.
|
|
|
|
|
Performing quantum physics with a nail brush and a small dog is easier than using Blender. I do a lot of 3D work and I have problems with Blender. I far prefer to use SoftImage|XSI and Maya to do the work. If you had the money, I would recommend Cinema4D because it is by far the easiest of these applications to use.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I posted this in the C# forum and then saw this forum on Graphics..(probably is better placed here, please excuse the double post)
I'm trying to draw lines that will show up as overlays on top of the buttons that I am drawing. The buttons are just standard buttons with images on them, but they occlude the lines when I draw the lines in the Form on paint method. Is there a way to paint the lines after the buttons have been drawn, in order to make the lines visible on top of the buttons?
I thought of a transparent form overlayed that I could draw to, but I thought that this would stop me from interfacing with the buttons.
Any Ideas?
James
|
|
|
|
|
Painting on the form doesn't work, because all form drawing takes place on a layer behind the controls. I see two possible solutions, depending on what you're trying to accomplish...
1) If you just need to draw something on the button itself, try subclassing the button and inserting your own OnPaint code (After a base.OnPaint call)
2) If you're drawing on both the form -and- the button, like an arrow pointing to the control, your transparent form idea might work.
It might take some tweaking, but you can override the WndProc method to pass the WM_NCHITTEST message (I think that's the one), always returning the value for Nothing (I think the constant is called HTNOTHING).
Windows calls this when the user tries to interact with something, to determine which process/thread/control should receive the event. This basically tells it that your form isn't really there, as far as input is concerned.
|
|
|
|
|