|
Wizard_01 wrote:
Does anyone know format of RegionData ?
Can you be more specific in what you are asking? The RegionData Class[^] class is listed here in MSDN.
-Nick Parker
|
|
|
|
|
I am trying to save at bitmap that has been loaded with
bitmap = (Bitmap) Bitmap.FromFile(FileName);
When I try to save it again with bitmap.Save(FileName); I get an error message:
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll
Additional information: A generic error occurred in GDI+.
If I try to it save with bitmap.Save(FileName2); everyting is fine, but it's not ok to me that you have to give the bitmap a new name. It's like the file is blocked by the system.
I have noticed that the Image Processing for Dummies by Christian Graus have the same problem. How to solve that?
|
|
|
|
|
While working on an Image Processing App I encountered the same kind of
generic error while using the Bitmap.Save() method. I did some searches in the www and it turns out that the Image/Bitmap class uses some type of on-demand loading scheme that requires the file to be open all through the object's life (therefore minimizing the amount of memory being used by big images)
This creates several problems. For instance, when you call the Image.Save("filename") to save the image to same file from where it was loaded, your program crashes because it is trying to overwrite an open file.
One workaround for this would be to save the changes to another file or to use unmanaged code to load all the image to memory.
If the bitmap is not too big you might also consider caching the bitmap in memory, ie:
1. Open the bitmap
2. Do a Bitmap.Save to a memoryStream
3. Dispose of the bitmap object and work with the memorystream
4.When your work is finished save the memorystream to a file.
But be carefull with this last approach when working with big bitmaps (big overhead)
|
|
|
|
|
Well - what is big bitmaps? Mine is about 3000px x 2000px, and i'm making the program as mdi, so there could be up to 20 bitmaps loaded into memory, but of cause you only would have to save one bitmap at the time. Anyway, i'm kind of new to c# (only been programming for a few weeks), so i'm not sure about what memoryStream i about yet. Might the be any othe solutions?
|
|
|
|
|
Well, How about this way?
1. save the bitmap using another name, say temp
2. Delete the old bitmap file
3. rename temp to the old bitmap name.
I realize that this is probably a long way around, but it'll probably save memory for thos big bitmaps
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Thanks, I will try that solution. I have just testet the method with memoryStream - it works, but it used 600 MB of memory!!! I only have 256 MB RAM, so my harddisk went totaly crazy, and even after I had shut down the program, Windows has totaly wierd.
|
|
|
|
|
Hey
I have i Rich Text Box that displays som info with out a visible scroller Vertivcal.
I read a txt file in to a string thats add one char to a temp string(one per second).
This temp string is then loaded in to the Rich Text Box.
I also Selects the last char in the Text Box so its scrolling to the buttom.
With other words, a simple Type writer that writes one char per second.
The problem is:
Every time a adds a char to the temp string and updates the text box with temp string, then it look a bit strange.
Maby you could tell me how to scroll in a Rich Text Box by code.
//Jimmy
|
|
|
|
|
Here is some code I scrolled a Rich Text Box with:
<br />
RichTextBox oBox = this.richTextBoxData;<br />
<br />
string strVbCode = "";<br />
<br />
bool fBold = false;<br />
<br />
int iIndex = 0;<br />
<br />
while ( iIndex < (oBox.TextLength) )<br />
{<br />
oBox.Select(iIndex,1);<br />
<br />
if (null != oBox.SelectionFont)<br />
{<br />
if (true == oBox.SelectionFont.Bold)<br />
{<br />
fBold = true;<br />
}<br />
}<br />
}<br />
I stripped out a bunch of stuff that was irrelevent to your question.
I'm not sure if this is your problem though. I'm wondering if when an RTF box redraws, it replaces the entier text instead of just the one new char and that is what messes up the way it looks. If so, then you might have to override the redraw event handler on it yourself (which may be a pain in the neck).
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Hi,
after having browsed a lot of sites and read a lot of msdn, now I have still my problem. I'm trying to read codec name from an avi file. I'm using this structure:
typedef struct {
DWORD dwMaxBytesPerSec;
DWORD dwFlags;
DWORD dwCaps;
DWORD dwStreams;
DWORD dwSuggestedBufferSize;
DWORD dwWidth;
DWORD dwHeight;
DWORD dwScale;
DWORD dwRate;
DWORD dwLength;
DWORD dwEditCount;
char szFileType[64];
} AVIFILEINFO;
which I have done by reading http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmstr_1xf6.asp
.... How can I exctract the codec name used to encode the avi file?
|
|
|
|
|
codec? avis aren't compressed
|
|
|
|
|
The Limey wrote:
avis aren't compressed
They certainly are.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I stand corrected, some are some aren't
|
|
|
|
|
A basic uncompressed avi 320x 240 takes up roughly 10MB per second. Play around with VirtualDub.
<a TITLE="See my user info" href=http:
|
|
|
|
|
uhm, so after having understood that an avi can be compressed (:P) ... in the end I've not understood how to extrac codec information from .avi files ... is it possibile using that structure?
|
|
|
|
|
No, and it is not really possible to get codec info. The codec specifies a FourCC code that is mapped in the system to a codec. More info I do not have.
<a TITLE="See my user info" href=http:
|
|
|
|
|
I am trying to play around with automating menu creation through external XML files. I've used several of the examples found in Code Project and I'm trying to bind the menu items to the MagicLibrary menu classes.
I'm getting close...but I'm stumped by trying to invoke a method in the calling application from my menu helper class. What I have is the following
The menu helper class is created by the main application and it reads the xml file and creates all the MagicLibrary MenuCommand items..that all seems to work fine. Within my menu helper class I have hooked into the menu click event and have the following method. The method retrieves a previously found and saved MethodInfo item that matches the actual method I want to call in the main application
private void menu_Click(object sender, System.EventArgs e)
{
object[] args = {sender, (object)e};
MethodInfo mi = (MethodInfo)onclickList[ (string)mc.Tag+".Click" ];
if (null != mi)
mi.Invoke(null, args);
}
The method I'm trying to invoke in the main application looks like the following
public void menuNew_Click(object sender, System.EventArgs e)
{
//* Code to do stuff in my application based on the menu click
//* event
}
What I get is an unhandled exception
An unhandled exception of type 'System.Reflection.TargetException' occurred in mscorlib.dll
Additional information: Non-static method requires a target.
Which has me stumped. I'm obviously not doing something right but I don't know what I'm missing.
Any help would be appreciated.
Thanks
Neil Lamka
neil@meetingworks.com
|
|
|
|
|
Neil Lamka wrote:
mi.Invoke(null, args);
You need to pass the object you going to invoke the method on.
<a TITLE="See my user info" href=http:
|
|
|
|
|
Pass in the form object as the first parameter to invoke.
|
|
|
|
|
How can I set text for a cell in UNBOUND columns in DataGrid?
|
|
|
|
|
Hello,
I have come across a strange behaviour.
I typed the following code:
<br />
[DllImport("urlmon.dll",CharSet=CharSet.Auto)]<br />
public static extern uint URLDownloadToFile(<br />
IntPtr pCaller,<br />
string szURL,<br />
string szFileName,<br />
uint dwReserved,<br />
IntPtr lpfnCB);<br />
<br />
string URL="http://www.boursorama.com";<br />
URLDownloadToFile(IntPtr.Zero,URL,"c:\test.html",0,IntPtr.Zero);<br />
When I run it (using the debugger), the function doesn't seems to send back an error and the function seems actually to work but I get no local file ! I even looked at the HTTP requests and I can see the HTTP GET issued and the 200 OK response.
I don't understand and I need UrlDownloadToFile (WebClient doesn't work with the IE cache).
I'm using the 1.1 framework on Windows 2000 Professionnal.
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
GriffonRL wrote:
"c:\test.html"
Have you tried "c:\\test.html"? The double backslash is needed to escape the \, other wise you wind up with \t which is the tab character.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
try @"c:\test.html" instead. The @ character means a string literal with no escape sequences.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Hello,
Thanks for answering but look at that:
URLDownloadToFile(IntPtr.Zero,"http://www.kimo.com.tw",@"c:\test1.htm",0,IntPtr.Zero);
<-- create the file
URLDownloadToFile(IntPtr.Zero,"http://www.yahoo.com",@"c:\test2.htm",0,IntPtr.Zero);
<-- create the file
URLDownloadToFile(IntPtr.Zero,"http://www.boursorama.com",@"c:\test3.htm",0,IntPtr.Zero); <-- doesn't create the file
Any idea ? Try by yourself.
R. LOPES
Just programmer.
|
|
|
|
|
Hello,
Thanks for answering but look at that:
URLDownloadToFile(IntPtr.Zero,"http://www.kimo.com.tw",@"c:\test1.htm",0,IntPtr.Zero);
<-- create the file
URLDownloadToFile(IntPtr.Zero,"http://www.yahoo.com",@"c:\test2.htm",0,IntPtr.Zero);
<-- create the file
URLDownloadToFile(IntPtr.Zero,"http://www.boursorama.com",@"c:\test3.htm",0,IntPtr.Zero); <-- doesn't create the file
Any idea ? Try by yourself.
R. LOPES
Just programmer.
|
|
|
|
|
Hello,
I have been playing a lot with the WebBrowser control past weeks and I successfully implemented the IDocHostUIHandler interface with it.
I'm now turning my focus to the InternetExplorer object. But I'm starting wondering if the IDocHostUIHandler interface works with this object. Until now I have got error when trying to cast the document object of the InternetExplorer object into a ICustomDoc object. The cast is invalid.
Is it possible to use the IDocHostUIHandler interface with the InternetExplorer object ? And if so, how to do it if I can't use the ICustomDoc interface to set the UI handler.
Thanks,
R. LOPES
Just programmer.
|
|
|
|