|
|
You have System.Diagnostics.Trace and log4net framework.Just google and will find plenty of articles & tutorials how to use them.
Life is a stage and we are all actors!
|
|
|
|
|
hello dear hristo bojilov
i want to have my own logger application !
witch could save and retrive my own data
the case is having a sample log application to get it`s adiea or customize that app for my own intention
|
|
|
|
|
Hello everyone,
I have a bitmap object that is created in C# and I want to share this bitmap between managed and unmanaged code.
So, I have something as follows in my C# code:
void DrawGraphic()
{
BitmapData bitmapData = myBitmap.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadWrite,
PixelFormat.Format32bppArgb);
}
Is there a possibility to pass the BitmapData pointer to my unmanaged code and then use the result? So, I do not want to create a copy but somehow share this bitmap data.
Thanks for any help you can give me.
Thanks,
Keith
|
|
|
|
|
GCHandle[^] may be what you're looking for...
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
There is no need for GCHandle . Basically passing an image is very similar to passing an array, however bitmapData.Scan0 is an IntPtr which you can pass straight to a native function that expects a pointer, say int* or char* . You should be aware of the number of bytes per pixel, their order, and the stride (the distance in pixels between consecutive rows could be larger than the image width). And you should not natively abuse the pointer by writing outside the bmpData area of course.
I don't have a bitmap example handy, I can offer two articles on passing arrays though:
- http://www.perceler.com/articles1.php?art=marshalarrays1[^]
- http://www.perceler.com/articles1.php?art=pinvoke1[^]
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
You have GetHbitmap() method and it fits to HBITMAP unmanaged type.For example if you use MFC inside your unmanaged lib code you could assign it directly to CBitmap class instance.
Life is a stage and we are all actors!
|
|
|
|
|
That is probably correct; my guess is it also copies the image (using cycles and bytes), which other methods don't.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi,
I want to copy the image data into a bufferby Image.fromfile(..); then i want to modify this data and then redraw the image ... how to do it... can anybody tell me
|
|
|
|
|
It depends on how you want to modify it, but assuming it is just draw or write on an image then you have most of it already:
Bitmap b = Image.FromFile(path);
using (Graphics g = Graphics.FromImage(b))
{
g.DrawLine(Pens.Black, 0,0, 100, 100);
g.DrawString("Hello", Font, Brushes.Black, new Point(0, 0));
}
Then either display the bitmap in a PictureBox control, or paint it on your form in the Paint event.
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
If you want extreme control over individual pixel colors:
Bitmap bmp = new Bitmap(FileLocation, true);
Color pix = bmp.GetPixel(X, Y);
bmp.SetPixel(X, Y, pix.A, pix.R, pix.G, pix.B);
|
|
|
|
|
How to set security for a given folder WRITE access permissions or grant full access for all users on a computer and for NETWORK SERVICE user.
Чесноков
|
|
|
|
|
I'm no expert when it comes to this, but perhaps the technique I used in this tip[^] will help?
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
well I need to get first built-in users and NETWORK SERVICE identifiers and add some access rules for them.
how do I get them?
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: NETWORK SERVICE identifiers
No idea I'm afraid.
Chesnokov Yuriy wrote: get built-in users
Add a reference to System.Management and add the same to your usings...
SelectQuery query = new SelectQuery("Win32_UserAccount");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject managementObject in searcher.Get())
{
Console.WriteLine("Username: {0}", managementObject["Name"]);
}
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi,
I want to remove the changes done to an image and get back the original image. the image might be modified by others and saved. If there is a single copy then how to remove the change
|
|
|
|
|
Unless you keep track of every change in some undo buffer which is somehow linked to the original then you cannot do this.
It's time for a new signature.
|
|
|
|
|
Restore from backup.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
|
i have two c# projects (ex : A and B), A is the main project and i add my B project to A, then i added a reference to A from B , now i can use the classes in B in A, but now i need to use some classes in A in side B, but i can't add reference from A to B because of circular reference , is there any way i can do this without adding that class to B project .
|
|
|
|
|
You could create a third assembly ("C") that both of the other assemblies reference but other than that, no.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
You're doing something wrong -- re-architect.
|
|
|
|
|
As John said, you would need three projects (two EXE, and one DLL referenced by both EXE).
Unless you were willing to merge all the functionality in a single EXE of course.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
|
Big mistake...
I've avoided it for decades, as Windows makes it so hard to do - at least through the eyes of a tyro. But it's time I learned it, and I sat down tonight intending to do so. I thought I'd start with drawing a simple circle on a form, and searching in Help returned a likely bit with sample code for drawing a rectangle and a circle within it, along with a button_Click handler to call the drawing function. I copied and pasted the sample code into my 800x600 form, just to try it out. Then I added a button1 object to provide the event. The code is:
public partial class FlowCalcs : Form
{
public FlowCalcs()
{
InitializeComponent();
}
private void DrawIt()
{
System.Drawing.Graphics graphics = this.CreateGraphics();
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(
100, 100, 200, 200);
graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle);
graphics.DrawRectangle(System.Drawing.Pens.Red, rectangle);
}
private void button1_Click(object sender, EventArgs e)
{
DrawIt();
}
}
When I debugged it, absolutely nothing happened - no rectangle, no circle, and no errors. I would welcome an error message, since occasionally Microsoft divulges some tiny bit of information that Google can find a solution for. But no such luck this time - it executes perfectly and does nothing.
Can someone lend a clue to the clueless? I haven't any idea where to go next...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|