|
hmm, i am doing something wrong... i have not used the memorystream before...
i am not getting any errors during compile, but the png is not comming out at all (redx in internet explorer and "cannot be displayed" because it contains errors in firebird)
can you see what i am doing wrong?
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
fImage.Save(memStream,ImageFormat.Png);
byte[] j = new Byte[memStream.Length];
memStream.Read(j,0,(int)memStream.Length);
ctx.Response.ContentType = "image/png";
ctx.Response.BinaryWrite(j);
|
|
|
|
|
seems to be working with:
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
fImage.Save(memStream,ImageFormat.Png);
ctx.Response.ContentType = "image/png";
ctx.Response.BinaryWrite(memStream.ToArray());
thanks for the help!
|
|
|
|
|
Good deal. Glad to see someone else stumbled across that REALLY useful error message as well .
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Bitmap img = new Bitmap(100, 100);
img.MakeTransparent = color.white;
img.Save("myimage.png", System.Drawing.Imaging.ImageFormat.Png);
img.Dispose();
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
any way i can get my images to look a little nicer, perhaps some anti-aliasing?
currently it looks like:
(note transparent png doesn't seem to work in IE, firefox only)
This
|
|
|
|
|
I'm not sure what type of transparency you're currently building into this PNG.
If you're doing a color key where basically one color indicates 100% transparency, you can't really do something like anti-aliasing. Your image would have to know color of what it's being drawn on top of an anti-alias to that color (thus defeating the purpose of a transparent image ). People have this problem with transparent GIF's because they only allow one color in the pallete to be transparent (100% transparent).
If you can get an alpha channel going instead of a color-key (256 levels of transparency on 8 bits of alpha for instance), then you can have the edges do some anti-aliasing.
I'm not exactly positive of the best way to actually anti-alias, but I can tell you it's pretty much impossible for things with only 100% or 0% transparency (without knowing what you're being drawn on top of). One easy (cheesy) way to make it look better is draw the image at 2x or 4x and then resize (with a good resizing algorithm) it to the size you want (all with an alpha channel, in other words a 32-bit image).
Let us know how this turns out...
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
not too sure, i am a runtime drawing newbie
first i "Clear" the background with Graphics.Clear(Color.Transparent) then i draw a line and two strings on the graphic using Graphics.DrawString and Graphics.DrawLine
i just noticed the quality of the image descreased significantly when saving as a png with transparency, instead of a jpg...
i find it particularily odd that the transparent pngs that are generated are not compatible with internet explorer... i thought that the low quality pngs (8bpp) with transparency worked... yet there is not PixelFormat.8bpp that isn't indexed... and you can't draw on indexed bitmaps using Graphics
the purpose of this project was just to test out the drawing features and try to make something useful...
you can test it out...
it takes the string of a request and parses it into values of a "fraction" which it then draws
the first part is a hex colour, preceded by the pound indicator... or "p" in this instance.
then the font size in pixel format
then the numerator
and the denominator, with a final terminating comma.
Example for best results use a browser that supports transparent pngs
if you want to take a look at the code
Here
(anyone know of a utility for automatically formating in VS.NET style, for the web/html?)
|
|
|
|
|
How to use "GetWindow" in C#.net?
Thanks in advance!
|
|
|
|
|
someForm.Owner
The graveyards are filled with indispensible men.
|
|
|
|
|
Only if your nCmd parameter to GetWindow would be GW_OWNER .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You'll have to P/Invoke it like so:
[DllImport("user32.dll")]
private static extern IntPtr GetWindow(
IntPtr hWnd,
[MarshalAs(UnmanagedType.U4)] int nCmd);
private const int GW_HWNDFIRST = 0;
private const int GW_HWNDLAST = 1;
private const int GW_HWNDNEXT = 2;
private const int GW_HWNDPREV = 3;
private const int GW_OWNER = 4;
private const int GW_CHILD = 5; You could define those constants as a enum, then change the declaration from int to your enum in GetWindow (leave the MarshalAsAttribute as is) if you want, but it really makes no difference if these are private and you'll be the only one calling these.
You can get the window handle from Control.Handle , from which all controls (including Form ) derive. You can use Control.FromHandle with the return IntPtr to get the control, which you can cast to whatever you like (like a Form ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
how can i get the pixel width/height of a font formatted string?
i know it'd be possible to use a System.Windows.Forms.Label by setting AutoSize on, but this is an ugly way, especially since this is for a web project...
|
|
|
|
|
Graphics g = someControl.CreateGraphics();
SizeF stringSize = g.MeasureString(theString, theFont, theFormat...);
The graveyards are filled with indispensible men.
|
|
|
|
|
thanks now only if that worked semi-accuratly for height
|
|
|
|
|
Everyone, I have a bug which doesn't seem to be related to my code (no, really! ) but instead to my configuration. The following line:
Application.Run(new MyApplicationWindow());
throws a NullReferenceException. The MyApplicationWindow constructor executes in full, and the exception is thrown from within Application.Run; here's the stack trace:
StackTrace " at System.Windows.Forms.SafeNativeMethods.ShowWindow(IntPtr hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
Interestingly, I have two identical copies of this solution on my machine. One is tied to source control, and one that isn't. The one not tied to source control runs without a problem, but the one tied to source control throws the exception. The code also runs just fine on coworkers' machines.
I've reinstalled MDAC 2.8 most recently, and I also upgraded to .NET 1.1. I'm using the 2002 version of Visual Studio.
Anything obvious come to mind? I appreciate any help I can get here.
Jerry
|
|
|
|
|
First, I need to mention that VS.NET 2002 will not compile 1.1 apps.
What's happening is the message loop is processing some message (probably WM_SHOW?) and it is being dispatched to your form and the appropriate methods are ran to process it. The ShowWindow method is trying to use a reference that hasn't been correctly initialized and is thus null. I see two possible problems: 1) Your code has a bug in the constructor or InitalizeComponent method that leaves some reference null that the ShowWindow method needs or 2) You have somehow manifested a bug in the framework either indirectly by your code or the controls you have placed on the form or by the configuration of your computer.
Here's what I would do. Comment out different things in the constructor and InitializeComponent method in a trial-and-error process seeing if that eliminates the problem. Try removing controls one at a time and see if that eliminates the problem. Try googling the usenet groups for the exception and stack trace you have provided to see if anyone else has encountered the same problem and what they did to solve.
Most importantly, if you find the problem post back and let us know!
|
|
|
|
|
How could I get the number of (local - belonging to the same application) forms on the screen ?
There is a class Screen at System.Windows.Forms.Screen but it doesn't hold any variable of visible forms on the screen (of the current application). If the class has nothing to do with forms then why is it under the FORMS.Screen namespace at all, rather that just Windows.Screen ?
Regards, Desmond
|
|
|
|
|
if i am not mistaken, there is nothing in "System.Windows" except the forms namespace...
this is probably because the current .net windows gui system is called "Windows Forms"
as to counting the number of open forms, why not either make an inheritable form with a counter to use in your applications, or increment and decrement a counter when you open/close forms....
other then that all i can think of is using EnumWindows in user32, and checking the window titles...
|
|
|
|
|
I think it's easier just to derive a class from System.Windows.Forms.Form, overload it's constructor and add there itself to a arraylist MyForms, or something like that. That way I also don't have to identify the forms (if they belong to me not another application on screen).
|
|
|
|
|
sure it
wasn't sure that was your goal 
|
|
|
|
|
Anyone know where I can get icons to use in my app?
Most of what I need comes with XP so I'll use them but I need a few others aswell preferably with the xp look.
The smaller the mind the greater the conceit.
Aesop
|
|
|
|
|
A quick google reveals two stock icon sites:
http://www.iconpharm.com/
http://www.stockicons.com/
You buy the icons from the sites but they appear to have royalty-free distribution.
Sincerely,
-Ron
|
|
|
|
|
Thank you , they look good.
The smaller the mind the greater the conceit.
Aesop
|
|
|
|
|
http://www.iconarchive.com/
http://www.glyfx.com/
http://office.microsoft.com/clipart/default.aspx
|
|
|
|