|
Hello
Image image;
image.Save("image.bmp", ImageFormat.Bmp);
image.Save("image.jpg", ImageFormat.Jpeg);
Andrew
|
|
|
|
|
Thanks for the quick response! However, I still can't get it to work. Here's my code:
<br />
Pen myPen;<br />
Graphics g;<br />
myPen = new Pen(System.Drawing.Color.Red, 1);<br />
g = pictureBox1.CreateGraphics();<br />
<br />
g.DrawLine(myPen,1,1,30,30);
<br />
Image image;<br />
image = pictureBox1.Image;<br />
image.Save(@"C:\image.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
I get a NullReferenceExcetion was unhandled error. I'm not sure what that means...
Thanks much, Tim
|
|
|
|
|
Hello
Yes, it will fail. Because you did not initialize Image property of your picter box. If you need to save your drawing, you can use the next code:
Bitmap image = new Bitmap(100, 100);
Pen myPen = new Pen(System.Drawing.Color.Red, 1);
Graphics g = Graphics.FromImage(image);
g.DrawLine(myPen,1,1,30,30);
myPen.Dispose();
g.Dispose();
image.Save(@"C:\image.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
pictureBox1.Image = image;
Andrew
|
|
|
|
|
THANKS MUCH, ANDREW
|
|
|
|
|
I am developing a drawing tool and make Panel as drawing area. I set Autoscroll of the panel true in case that the drawing may be large. But
why the stroll does not appeat automatically?
How can I attach a scroll manually and when you drag the scroll, different part of the drawing apears in the drawing area.
Many thanks!
Radic
|
|
|
|
|
I am calling the Quit() method of the Word Object but sometimes I get an error saying a Dialog is still active. Anybody know how I can tell if a Dialog is still active before I call Quit()
notsnoj
|
|
|
|
|
i need to create some nunit tests for a method, but here's the problem.
i have an object InternalUser it has a method Authenticate(), this one fires events depending on authentication is successful or not.
public InternalUser Authenticate(string userName, string password)
{
Events.PreAuthentication(userName, password, State.PreAuthentication);
...more stuff here...
}
in events class
public static void PreAuthentication(...)
{
Application.Instance().ExecutePreAuthentication(...);
}
in application class
internal static Application Instance()
{
in here i use HttpContext so nunit fails saying no context here.
}
ihave other methods that do the same, but i cant create tests for these because nunit says no context available, any ideas on how i can get around this problem?
thanks
|
|
|
|
|
There isn't an HttpContext beccause you aren't running in asp.net. I've been thinking about modifing one of my articles to allow testing like this. Would you be interested?
For a quick fix, is there any way to mimic the calls you make to HttpContext if it is null? Ie. add code if (HttpContext.Current == null) //etc. If not, another short term solution is to use something like nunitasp.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
yeah id be very interested, i could change it to work without HttpContext.
i cant use nunitasp because the frontend pages havent been created yet.
|
|
|
|
|
after looking around google i found this
http://www.biasecurities.com/blogs/jim/archive/2005/08/11/2058.aspx, works like a charm
|
|
|
|
|
My C# app needs to call a C++ SDK ( for controlling a digital camera ). I started writing a MC++ dll to wrap it, but I've come unstuck. The SDK uses function pointers, and when I tried to put those in the MC++ app, they would not compile, because everything was garbage collected. __nogc on the class just caused new errors. I also tried building a standard C++ DLL and pInvoking it, but my early attempts were not successful. I'm thinking the third option is COM, however I want to pass Bitmap objects into C#, and also I need to pass a HWND from C# to the dll, for it to draw an image preview on to.
What's the best way for me to go about this ? Is there a way around the MC++ problem ? It seems the best idea to me, but as I've come to a problem, I'm stopping to re-evaluate my approach...
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
The SDK uses function pointers, and when I tried to put those in the MC++ app, they would not compile, because everything was garbage collected. __nogc on the class just caused new errors.
Compile all unmanaged code as unmanaged, without /clr. But its weird you say it cant deal with function pointers. What errors are you getting?
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
leppie wrote:
Compile all unmanaged code as unmanaged, without /clr.
How do I then call it from C# ? Where does the MC++ code go into it ?
I get errors like this :
d:\Contract Work\Fotovision\Imaging\Imaging.cpp(121): error C2664: 'CDStartViewfinder' : cannot convert parameter 3 from 'cdUInt32 (cdVoid *,cdUInt32,cdUInt32,cdContext)' to 'cdViewFinderCallbackFunction (__stdcall *)'
d:\Contract Work\Fotovision\Imaging\Imaging.cpp(136): error C2440: 'type cast' : cannot convert from 'LPVOID' to 'Imaging::Canon __gc *'
The second was for passing this into a function.
If I put __nogc on the class, I get this:
d:\Contract Work\Fotovision\Imaging\Imaging.h(22): error C3381: 'Imaging::Canon' : an assembly access specifier can only be applied to a managed type
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am displaying all members of class Test:
Type ClassType = typeof(Test);
MemberInfo[] Members = ClassType.GetMembers();
foreach(MemberInfo Member in Members)
{
Writer.WriteLine("<" + Member.Name + ">" + <big>???</big>));
}
and I would like also to display in the same foreach loop values of these members of given object Test. How to make it?
|
|
|
|
|
Make the function recursive, and keep calling it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I cannot see a difference... I must display a value of a member, but this member is different each time.
|
|
|
|
|
Because you don't know how deep you need to go, the program decides for you, by calling itself until there are no more properties to display.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
but how this function should know which member is to be showned?
|
|
|
|
|
It needs to change from it's current signature to take an object and use reflection to work out what the properties are on the object, and what the object is.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm... but still, I don`t know how to display the value of the member after using reflection...
Maybe could you support your post with code/pseudo-code of that function?
anyway, tnx for your time
|
|
|
|
|
Oh, sorry. I thought you wanted to walk objects that were properties and had properties. You want to walk the objects you're walking now, and get their values. Try this[^] article for info.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
use recursive function function which call its self
MCAD
-- modified at 18:03 Monday 5th September, 2005
|
|
|
|
|
Hi,
I'm trying to find a way to do something like CustomDraw in a Windows.Forms.ListView.
What I want to do is: reuse the scrolling, selection, and column resizing, but draw each "cell" manually.
I found references to Owner/CustomDraw only in .NET 2.0 (that's VS8, right? )
Is this possible?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
The only way I know of with 1.1 is to subclass ListView and override the WndProc method and listen for the relevant messages (like you would with a non .Net app). This article[^] is a pretty good example.
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
Hello All,
I am tring to redrew the button to be a Circleur button. but affte i did it there is a rectangle apper when i click the button.
How can i remove this rectangle or disable it?
Regards
Hay
|
|
|
|