You can just do img.Save("test.jpg", ImageFormat.Jpg)
and it will save the image.
When you draw using Graphics that was created from image, all the drawing is happening on the image surface, so if you save the image, all drawing will be kept.
I have been working on a Windows App with three tabs in it (using the tabControl control). I have placed between 15 and 20 objects on each tab (labels, buttons, dropdowns, etc.) and made all of the backrounds transparent. Then I put a different image as the background of each tab, which creates this sort of watermark effect, which I really like. Unfortunately, when you swtich back and forth between the tabs in the .exe, it takes a few seconds each time to redraw all of the GUI objects, which looks pretty bad.
Does anyone have a solution for this problem? A way to draw the tab completely before displaying it? Background image as a GDI+ object? Double buffering?
I've got a plugin arcitecture system that calls LoadFrom to load the .dlls in a specific folder and it works fine and dandy, imports everything, my code can create objects from types found in the loaded .dlls
HOWEVER, One issue i've not been able to solve is that, in some of the classes, I've got custom Type Editors for some of the classes in the "plugged in" .dlls
Whenever I set a created object from one of the plugged in .dlls and set it to a property grid's selected object, trying to edit it does not produce the correct type editor. This is especially the case with my custom collection classes. Since most of them are inherited from ArrayList, I constantly get the Object editor form.
Now here's the really wicked twist. If the plugins are set to references in my project in vs.net, The correct editors will appear just fine.
I did some debugging by getting a type for one of my collections that uses a custom editor, and wrote all the attributes from GetCustomAttributes method and the System.ComponentModel.EditorAttribute was still a recognized attribute on the class, eliminating my thought that perhaps the attribute was being lost during the LoadFrom.
I'm getting "System.OutOfMemoryException" in a block of code that has not changed in quite a while. Actually it is an instantiation of a User Control. There are a series of 4 UC's instantiated. The first one has had changes made to it. The remaining have not. If I comment out the second one, the error goes away.
The problem is that the error doesn't show up until I do the Show() on the containing form. How do I figure out what causes an error like this when
1. No changes were made to this UC
2. An error doesn't occur when instantiating the UI
3. Memory does not peak at all
4. Changing the first UC back to it's original form corrects the problem.
Commented out basically the entire UC and kept uncommenting until I found the line of code causing the error. It wasn't an OutOfMemoryException, due to the other changes the code was hit a reference to a NULL object.
There's got to be a better way to track those down...but misleading error messages don't help. Still not sure why the error reported as it did (after the other two UCs created and then upon parent form doing its Show method) because the problem does get encountered during form creation.
After performing calculation, a data need to be displayed. But the function SetWindowText() can only take parameter in string data type. How to convert the int and float into text form so that it can be displayed in the dialog using edit box (in MFC)?
What do you mean by "the database is bad"?
Without providing a more detailed error description it's very hard to help you!
Just one thing that comes to mind: Do you disable your timer while your function is executing? If not, the cause for your problems could be the timer re-entering the function while the previous timer event is still executing...
You may want to try Compact and Repair Database. We have a system that has the UI and Database separated. The front end never changes but it continues to grow just from using it! Since there is no data changes being made, I know that there are "features" in .mdb files that just need routine maintenance.
Access doesn't reclaim disk space when deleting or altering recrods until you tell it to do a compact and repair. Also, indexing sometimes places pads so that it can be better optimized. Really, it isn't a problem if you do regular housecleaning.
I have a strange problem with C# and the Graphics-class.
My Form contains a pictureBox, on which a black and a red rectangle is drawn as soon as the user clicks on it. The Red Rectangle uses Color (200,255,0,0), so an Alpha value for transparency. The result can be seen here:
As you can see, the red rectangle is NOT rendered in the vincinity of the Mouse cursor (the mouse icon), you can see the black Rectangle through it. This happens ONLY if the Red Rectangle has an alhpa value which is NOT 0 or 255. 0 and 255 work of course.
This error happens only on my computer and a similar one (both have Windows 2000 and a Matrox G450 Millenium graphics card), on another computer with WinXP and another graphics card the same code works perfectly.
All current drivers and ServicePacks fpr GDI, GDI+, Windows 2000, Visual Studio .NET 1.0 (Service Pack 2) are installed.
Now, I would like to know if the error occures because of the
a.) Graphics card
b.) Windows 2000
c.) Visual Studio .NET
e.) my fault?
Who already encountered something similar and knows help?
I've already spent hours in searching at msdn and google, but did not find anything.
Don't know if it really has something to do with the problem you're experiencing, but you could take a look at the color depth of your display.
I remember having troubles with the TransparencyKey of System.Windows.Forms.Form when used with 32bit color depth. Using 16 or 24 bpp worked fine, using 32bpp required a workaround to get transparency to work.
So if you're using 32bpp you should switch to 24bpp and test whether the problem still persists.
Of course I can, but I don't know if this will help you because the workaround is used to make parts of an image completely transparent and you said you wanted other alpha values than 0 or 255...
Anyway: The usual approach to make parts of a Form transparent is to assign a BackgroundImage and set the TransparencyKey to a color in your image. This works with color depth up to 24bpp, with 32bpp it seems to fail completely (i.e. you see your mask color, no transparency at all).
The suggestion some MS guy made was to first load the image, then make it transparent using Bitmap.MakeTransparent() and then setting the TransparencyKey to what you receive from calling Bitmap.GetPixel() for a pixel position you know to hold the mask color.
In code that means (used in the Load event handler of a Form):
There is no standard way - this is what programs do. You must decide the saving and loading routines.
If you want to write a text file, you can use a TextWriter derivative, like StreamWriter or simply use File.CreateText. When you read it, use a TextReader or simply File.ReadText (which returns a TextReader, an abstract class for other classes like StreamReader.
If you want to write binary files, you can use FileStream to both read and write.
If you want to store these attributes (like the phone number) in an object and serialize that to XML (a text format), then use XmlSerializer defined in the System.Xml namespace.
There's really a seemingly infinite ways of accomplishing this task and it all depends on what you want to do. This is a basic concept, however. I recommend that you read the .NET Framework SDK - especially the programming topics - and pick up a book or two on developing applications with .NET. If you read the .NET Framework SDK - and you should - the class documentation for those classes I mentioned above even have examples.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering Microsoft