|
|
I tried this
Line l = new Line();
l.X1 = 0;
l.Y1 = 0;
l.X2 = 100;
l.Y2 = 100;
l.Stroke = Brushes.Black;
canvas1.Children.Add(l);
canvas1.UpdateLayout();
RenderTargetBitmap rmi = new RenderTargetBitmap(
(int)canvas1.ActualWidth, (int)canvas1.ActualHeight,
1 / 96, 1 / 96, PixelFormats.Pbgra32);
rmi.Render(canvas1);
Can you tell me what to do next in order to get array of pixels.
|
|
|
|
|
Here's an example (you can use a different encoder and/or output to a different stream type if necessary) :
Saving you canvas to image[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks the link helped.
But the article doesnt explain how to get the pixel values in an array.
I want the pixel values in a 1-D or 2-D array.
|
|
|
|
|
AmitDey wrote: I want the pixel values in a 1-D or 2-D array.
Maybe RenderTargetBitmap.CopyPixels() ?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Just another day at the CodeProject Documentation Proxy Office eh?
Where do you want to go today?
What documentation don't you want to read today?
led mike
|
|
|
|
|
Hello, I'm receiving the following error message. I know I'm missing something simple, but I can't figure out what it is.
Possibly a local DLL security issue? I have been able to reference winmm.dll 's other methods without a problem though.
The only thing I can think of is I'm sending invalid Types.
Tested in VS 2005 (.NET 2.0), and C# Express 2008 (.NET 3.5)
Thanks for any help anyone can provide.
Microsoft's Documentation of mciGetErrorString...
http://msdn.microsoft.com/en-us/library/ms709479(VS.85).aspx[^]
Error Message...
AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Code...
class Program
{
[System.Runtime.InteropServices.DllImport("winmm.dll")]
private static extern bool mciGetErrorString(long errorCode, string buffer, int iReturnLength);
static void Main(string[] args)
{
long error = 19703256959680778;
string text = "";
mciGetErrorString(error, text, 128);
}
}
modified on Wednesday, August 6, 2008 11:28 AM
|
|
|
|
|
Now that I have been looking at it, it seems the line "long error = 19703256959680778;" value may have been invalid.
What I have been trying to do is simply get the string value of the error code returned by mciSendString in winmm.dll
I have been trying out the MP3 Player at
http://www.codeproject.com/KB/audio-video/MP3Example.aspx[^]
and I wanted to add some more descriptive error reporting to the mciSendString return value calls.
I haven't been able to find any clear C# documentation of using the mciSendString error in mciGetErrorString.
I hope this helps to explain a little more.
|
|
|
|
|
I'm not an expert at making native calls but there are a few things that don't look right to me.
1) C# long is not necessarily the same as C/C++ long .
2) In mciGetErrorString param #3 represents the length of the buffer that param #2 points to, but you're passing in an empty string which is length zero and telling mciGetErrorString that it's 128 chars long. I think to return a string from native code to managed code you need to create a StringBuilder of the appropriate length and use that. In the article you linked to see how he used a StringBuilder for the variable strReturn in the declaration of mciSendString even though when he calls that function he passes null for the string pointer and zero for the length.
Hope that helps.
|
|
|
|
|
Yep, you guys were right on. The C++ to C# conventions types threw me a bit off. TY TY.
Now... You wouldn't have any idea why I can make winmm.dll MCI device calls from a windows forms app but not a console app? I believe a windows forms app uses the default sound device, but the console app attempts to use it (the default one windows is probably holding onto) and windows tells it...
"Unknown problem while loading the specified device driver."
This error shows up regardless if the audio file path is valid or not.
I would think the windows console process would have access to the windows audio devices.
I used the final code below to generate the error. Works in a form app, not in a console app.
VS 2005, and C# 2008.
Any ideas?
Code is as follows...
class Program
{
[System.Runtime.InteropServices.DllImport("winmm.dll", EntryPoint = "mciGetErrorString")]
public static extern bool mciGetErrorString(int dwError, StringBuilder lpstrBuffer, int uLength);
[System.Runtime.InteropServices.DllImport("winmm.dll")]
private static extern int mciSendString(string strCommand, string strReturn, int iReturnLength, IntPtr hwndCallback);
static void Main(string[] args)
{
string Pcommand = "open \"" + "C:\\SomeNonExistantFile.mp3" + "\" type mpegvideo alias MediaFile";
int err = mciSendString(Pcommand, null, 0, IntPtr.Zero);
StringBuilder text = new StringBuilder(128, 128);
mciGetErrorString(err, text, int.MaxValue);
Console.WriteLine(text);
Console.WriteLine();
Console.WriteLine("Press Any Key");
Console.ReadKey();
}
}
|
|
|
|
|
audio yes, but video no. the type in your Pcommand is mpegvideo , but should a console app be able to play movies? the command succeeded when i tried it with a type waveaudio ..
Also, if you pass a value into mciGetErrorString that is larger than the space that you have allocated for the buffer, then it will be able to write to invalid memory. Since the SB has a capacity of 128 it makes sense to pass in 128 instead of int.MaxValue
good luck
|
|
|
|
|
Yeah, good call on the SB, I just ran into the overflow problem. I made that change. Thanks!
Your right concerning the type also.
The reason I was using the mpegvideo instead of waveaudio was the decoder/codec functions of the mpegvideo option (specifically MP3's) eg. console mp3 player. From what I can tell, I have been unsuccessful in getting waveaudio to use MP3's. I believe it was designed for raw WAV's only.
I was hoping to stick with winmm.dll for the consistency. Any suggested workarounds? Time for a new lib?
Thanks again for all of the help.
|
|
|
|
|
|
Thanks for the links.
It looks like the MCI open string doesn't work the way I want it to, but by using the play command, and never even using the open command, it works... shrug.
Another person was having the same issue at the bottom of this page...
http://gmc.yoyogames.com/lofiversion/index.php/t743.html[^]
I'll check out those links you provided me too. Thanks again!!
|
|
|
|
|
Jimmanuel is right on the money....
You need to use the appropriate types to interop.
DWORDs will never be a C# long - they are always unsigned 32-bit ints.
A BOOL is an int, which is a 32-bit signed int.
As Jimmanuel mentioned, you also can't use a string as an out parameter like that.
Put that all together and something like this should work:
[System.Runtime.InteropServices.DllImport("winmm.dll")]
private static extern int mciGetErrorString(UInt32 errorCode, StringBuilder buffer, UInt32 iReturnLength);
I tested this with the following code and it worked:
StringBuilder sb = new StringBuilder(260);
mciGetErrorString(256+37, sb, 260);
Console.WriteLine(sb.ToString());
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
i want to trace my application to get information how much memory allocate to each objects and ...
does visual studio has this tool ? (i don't implement this by code, i want to trace my app visually)
how to do ?
thanks
|
|
|
|
|
I want to display doc file in my C# Application
how can I do it?
Do you have any viewer about it
Thanks in advance
Hello Friends
|
|
|
|
|
You can do this through VSTO or other third party software.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
You can use the Office Interop Library, but that is going to require your users to have Office installed.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Microsoft Office Word Viewer 2003 lets you view and print Word documents on a computer that does not have Word installed. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
889347 (http://support.microsoft.com/kb/889347/) Description of the Microsoft Office Word Viewer 2003
Vikas Amin
UNITED STATES STEEL CORPORATION
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
many but not all doc files open without any issue with WORDPAD
Vikas Amin
UNITED STATES STEEL CORPORATION
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
|
|
ahaa, I found the problem. If the html source has a big VIEWSTATE, it doesn't respond.
when I put spaces somewhere in the big viewstate regex was responded.
Now I'm removing all viewstates's values
It's working perfect
I want to fly but I don't have wings
modified on Wednesday, August 6, 2008 12:55 PM
|
|
|
|