|
How do you expect this to work ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I would presume that it would be run in a web server, perhaps as a Service. When a request is made for the stream, it would iterate through each of the given System.IO.Streams and send the data. When a System.IO.Stream is at the end, it would move to the next System.IO.Stream and repeat the process.
Of course, this would probably have its own set of problems, like handling different file formats.
At least, that's how I read it
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I read it that the multiple streams are simultaneous. Otherwise, it doesn't seem like it's a big issue to me, depending on what the streams are, it could be trivial
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I was hoping one filestream to read multiple byte[]'s....
All byte[]'s would be pdf files...
Newbie at the whole streaming thing...not sure if this is even possible..
Thanks,
ZachBob
~Any help is good help
|
|
|
|
|
If you're going for PDFs, then you shouldn't be reading them as raw byte arrays. Use a PDF reading library, put all the pages into one byte array, then send that. You could theoretically stream it one page at a time to save memory, but I can't help you with that
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I was thinking of reading the byte[]'s into a filestream...?!?!not really sure...kind of new to the streaming process...or is this a unrealistic thought??
Thanks
~Any help is good help
|
|
|
|
|
Why can't you stream one array after another until all arrays have been sent?
The client end doesn't care how many arrays it took on the server to compose a stream.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi guys! I have an image that I need to process. Actually I want to change brightness and contrast level. I tried to use a lot of algorithms and filters for processing such as AForge.Imaging.Filters, Color Matrix and many many others but no one can't provide a high processing performance. The main idea - to make a program which will allow to change brightness and contrast of the image in realtime by using TrackBar component like it realized in Adobe photoshop or in Windows Vista Photo Gallery in Photo Editing mode. The main problem - processing performance. For small size images Aforge filters works perfectly, but if I try to process the image which has been made by the 9.0Mpx digital camera, with resolution 3712x2088 it becomes a really big problem. Aforge brightness filter works too slow for big bitmaps. If anybody know how to resolve this problem, please help. I wish to know how brightness correction works in Vista Photo gallery... It can change brightness for any image with any size in realtime with incredible speed even if you will shake trackbar pointer side by side. How did they realized it??
|
|
|
|
|
The easiest way to do this is with a color matrix set for brightness and contrast changes. Fotovision ( the MS sample ) has examples
Ultimately, those programs are faster b/c they are written in C, not C#
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
How is that different from yesterday's post[^]?
Pull this one again, and your brightness could become zero, as in blacklisted.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I've found one cool algorithm for brightness and contrast's change.
public static bool Brightness(Bitmap b, int nBrightness)
{
if (nBrightness < -255 || nBrightness > 255)
return false;
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
int nVal = 0;
unsafe
{
byte * p = (byte *)(void *)Scan0;
int nOffset = stride - b.Width*3;
int nWidth = b.Width * 3;
for(int y=0;y<b.Height;++y)
{
for(int x=0; x < nWidth; ++x )
{
nVal = (int) (p[0] + nBrightness);
if (nVal < 0) nVal = 0;
if (nVal > 255) nVal = 255;
p[0] = (byte)nVal;
++p;
}
p += nOffset;
}
}
b.UnlockBits(bmData);
return true;
}
public static bool Contrast(Bitmap b, sbyte nContrast)
{
if (nContrast < -100) return false;
if (nContrast > 100) return false;
double pixel = 0, contrast = (100.0+nContrast)/100.0;
contrast *= contrast;
int red, green, blue;
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
unsafe
{
byte * p = (byte *)(void *)Scan0;
int nOffset = stride - b.Width*3;
for(int y=0;y<b.Height;++y)
{
for(int x=0; x < b.Width; ++x )
{
blue = p[0];
green = p[1];
red = p[2];
pixel = red/255.0;
pixel -= 0.5;
pixel *= contrast;
pixel += 0.5;
pixel *= 255;
if (pixel < 0) pixel = 0;
if (pixel > 255) pixel = 255;
p[2] = (byte) pixel;
pixel = green/255.0;
pixel -= 0.5;
pixel *= contrast;
pixel += 0.5;
pixel *= 255;
if (pixel < 0) pixel = 0;
if (pixel > 255) pixel = 255;
p[1] = (byte) pixel;
pixel = blue/255.0;
pixel -= 0.5;
pixel *= contrast;
pixel += 0.5;
pixel *= 255;
if (pixel < 0) pixel = 0;
if (pixel > 255) pixel = 255;
p[0] = (byte) pixel;
p += 3;
}
p += nOffset;
}
}
b.UnlockBits(bmData);
return true;
}
This is 'pixel per pixel' algorithm with unsafe code which gives you a really great performance even for big images.
|
|
|
|
|
Hi,
Firstly, I am trying to create a quick hardcoded application to monitor the filesize of any file using FileSystemWatcher.
My problem is that the file I am trying to monitor is ALWAYS in use. This is expected because it is a data file that is always open by another application. I would like to see how the data file size changes over time.
If I try to access the properties of this file while it is in use, I get a file in use exception, which is kind of expected.
The event is triggered by a filesize change and it works if I do not try to access the file to get the filesize. But then this application would be meaningless.
To get the filesize, I am using the FileInfo class.
Does anyone know some workaround or how I can avoid this problem? (Without actually closing the data file) No need to go into a lot of detail, I'll google it but I could just use a hint though, if it's possible
Maybe I could somehow check the filesize on a system level? (i.e. the file size that windows sees and displays on rightclick -> properties instead of actually accessing it?)
Thanks,
See_Sharp
modified on Thursday, July 16, 2009 11:56 AM
|
|
|
|
|
This seems to work for me using FileInfo even if the file is in use...
foreach (FileInfo info in new DirectoryInfo(@"C:\test").GetFiles())
{
Console.WriteLine(info.Length);
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks Dave.
Yes you're right it does work, but I am dumb and FileInfo was looking in the wrong directory. I even double checked the path but I skipped a folder... how do people make these kinds of mistakes happens I guess, thanks for your reply.
|
|
|
|
|
Hi All,
I've been looking around for any pointers on how this might be 'dressed up' in some form of 'catch all' generic call to based on a string key value.
I guess this would involve reflection in order to get at the class properties. Has anyone come across something like this?
I would like to be able to use syntax like along the lines of:
public T GetSettingValue<T>(string key)
{
return (T)Properties.Settings.Default.Properties[key].Value;
}
Cheers,
|
|
|
|
|
|
You can draw directly on the form. This example just draws a diaganol line from top left to bottom right. Abviously you'll need to persist your points in a collection somewhere and alter the OnPaint accordingly, but it should get you started.
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
using (Pen pen = new Pen(Color.Black))
{
e.Graphics.DrawLine(pen, Point.Empty, new Point(ClientSize.Width, ClientSize.Height));
}
base.OnPaint(e);
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks for the help, i have used a similar code and it gives me one specific point(in form of a small ellipse is fine with me). how can i get similar points on mouse clicks.
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.DrawEllipse(Pens.Red, 100,100, 2, 2);
base.OnPaint(e);
}
please help
|
|
|
|
|
Grab the location of click in the Form's MouseDown event. Then, you can use them as center of your circle(point) and calculate the X and Y coordinates for the DrawEllipse method.
|
|
|
|
|
Something like:
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
List<Point> points = new List<Point>();
public Form1()
{
InitializeComponent();
MouseClick += new MouseEventHandler(Form1_MouseClick);
}
void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
points.Add(e.Location);
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
foreach (Point point in points)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.DrawEllipse(Pens.Red, point.X, point.Y, 2, 2);
}
base.OnPaint(e);
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi, All.
I need some solution to get the list of Types marked with user defined attribute.
I got few DLLs with definitions of protocol messages, which marked with some attribute ("MessageAttribute").
My mission is: to collect all Types marked with this attribute.
The DLLs - created by few different teams and have dependencies between dlls.
When I trying to load some dll by calling:
asm = Assembly.LoadFile(dllFileName)
and than to get Types list by:
asm.getTypes() - But here I get System.Reflection.ReflectionTypeLoadException.
As I see the exception caused by some Type from outer DLL.
All DLLs in same directory. I tryed also to add:
AppDomain.CurrentDomain.TypeResolve += new ResolveEventHandler(MyAssemblyResolve);
But id doesn't get into resolving function.
|
|
|
|
|
Did anyone know how to use NI-DAQmx USB600 to send out a voltage to change the input of device? any idea or suggestion? I have a GUI now, i wanna the GUI switch between Active high(5V) and Active low(0V).
|
|
|
|
|
This is the C# forum.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
YEP, i wanna use C# to program it.
|
|
|
|
|
Hi All,
I have a DLL file I am using in a .Net 3.5 Windows Forms Application, it is a 32-bit DLL.
Now when I run on 64-bit windows it does not work - Understandable.
I also have a 64-bit version of this file, but my question is how do I switch between the two? Obvisouly I could make two version of the application one for 32Bit that uses the 32Bit DLL and one for 64bit that uses the 64Bit dll, but is this needed? Can I not simply include the two version of the DLL in my application and somehow check which platform is running and use the relevant DLL to suite?
Any Ideas?
Thank you
P.S. My searching skills on this are not working (possible as I can not think of the correct phrase to search)
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|