|
Hi all,
Here's a quick question that has been bugging me for a while.
All I want to do is implement a ReplaceColor function for a given bitmap. I have written a simple version in GDI+ using ImageAttributes, ColorMap and Graphics.DrawImage, which works ok. It replaces a given rgb value with a new rgb value.
What I really want to do is include a threshold value. For example, if I had a bitmap of a red square gradient from red (255, 0, 0) to white (255, 255, 255). If the theshold value was high enough and the find colour was red (255, 0, 0) and the replace color was blue (0, 0, 255). The result would be a blue square gradient from blue (0, 0, 255) to white (255, 255, 255).
Any ideas? Is there a built in GDI+ method for doing this or would I need to write my own? I've seen the SetThreshold method of ImageAttributes, can I use this?
Thanks in advance
Andy
|
|
|
|
|
I dont think this is possible to do.
Just because the image is gradient of red and white, doesnt mean that only two colors are used. There can be many more (off white, light pink, dark pink...etc)
|
|
|
|
|
how can I realize a simple syntax highlightning richTextBox?
thanks
|
|
|
|
|
Your question implies that you are expecting a simple example that demonstrates how to implement syntax highlighting. Though not an impossible task, syntax highlighting is not a trivial one. I would start with Jan van den Baard's Brainchild and see if you can take what you learn there and port it to C#. There are others who have done this as well. I would just do a web search if Jan van den Baard's article and code doesn't help you.
Good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Is it possible to impersonate the caller of a method that is remoted? I have a remote component (which currently I'm planning to always run on the same machine as the client) that is hosted by a Windows Service. I want to run the service as LocalSystem yet impersonate the client user for some sections of code. Is this possible? Does it require COM+ and does that affect remoting?
|
|
|
|
|
Hey there guys,
I am trying to write a checkbox from the ground up. My problem is I want the box to be drawn vertically level with the baseline of the font (Baseline being where the Underline is drawn - just to clarify ). Does anyone know if there is a way to find for a given font where the base line lays?
Thanks,
()####CYBEROPPY=============>
|
|
|
|
|
Here's a scenerio. You all know those AIM chat windows? Say I want to write a C# winform that'll "eat" the chat window. The idea being I can take lots of AIM chat windows and put them all in the same form. (reduce taskbar clutter . . .)
I know this has been done in programs before, but they're all shareware and bloated. Obviously, I can do better. Plus, I won't learn anything.
So, any ideas? From what I've read, this will involve getting window handles via the win32 api. but this is new stuff to me. anybody have any ideas as how this would be done? tutorials on obtaining and manipulating window handles in C#? or any of you guys want to give me a quick tutorial?
Thanks,
-Alex
|
|
|
|
|
If I set Panel.AutoScrollPosition=blah blah blah right after the control is created, the scrollbars don't budge. But if I set the property as part of the OnPaint, they work fine. What's going on? All I'm trying to do is center the scrollbars when the control is created. I don't want to code a one-time "if" statement in the OnPaint!
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator.
|
|
|
|
|
Marc Clifton wrote:
I don't want to code a one-time "if" statement in the OnPaint!
Its only another if, yeah I hate them too, but thats what they there for! Unless you can do a switch perhaps?..
Cheers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
We have a manual process today where we do the following steps:
Take an XML file and create its' schema using XMLSpy.
We take the schema and treat this as a file-by-example and apply a transform against this file to create an object definition file. (which eventually runs through my wizard to create all the class libraries to access and update the original XML file)
I coding the frontend of the wizard mentioned above to transform the XSD file into our object definition file. In the framework all of the overloads for doing an XSLT transform put the document either through an XML Reader or starts with an XML Document -- which causes an XSD file to fail because it executes an XML validator. The transform method does not let me take in the XSD file as input and no overload supports taking an XSD file as input!!!!
Does ANYONE have a suggestion on how to execute an XSLT transform against a schema file!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
....just an added piece of input:
if anyone even knows how to invoke an xml.Transform() call with the xml validator turned off even THAT may get me past this problem!!
Thanks.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
This should be an easy question. I have a pointer to memory (a DIB), and I'm wanting to copy that memory to a Bitmap.
So, the second to the last line needs to copy from a IntPtr to an IntPtr. Problem is that Marshal.Copy will convert anything to a IntPtr, or an IntPtr to anything, but it won't copy from an IntPtr to an IntPtr.
So, how are you supposed to copy from one pointer to another?
Thanks!! Rectangle rcImage = new Rectangle( 0, 0, iWidth, iHeight );
m_CurrentImage = new Bitmap( iWidth, iHeight, PixelFormat.Format8bppIndexed );
BitmapData pBitmapData = m_CurrentImage.LockBits( rcImage, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed );
Marshal.Copy( hDibBitmap, pBitmapData.Scan0, 0, iWidth * iHeight );
m_CurrentImage.UnlockBits( pBitmapData );
|
|
|
|
|
psdavis wrote:
So, the second to the last line needs to copy from a IntPtr to an IntPtr. Problem is that Marshal.Copy will convert anything to a IntPtr, or an IntPtr to anything, but it won't copy from an IntPtr to an IntPtr.
So, how are you supposed to copy from one pointer to another?
Why on earth do you wanna do that? Why not just use the pointer?
OK I see what you are trying to do...perhaps Marshalling is NOT what need. Also you lock the memory as ReadOnly, then try to copy to it.... something strange! I have not worked with this before but AFAI can see you mite need to use ImageLockMode.UserInputBuffer...
Cheers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
Because Microsoft told me to!!
In general, you may take the following steps to create a Bitmap from a DIB with GDI+:<br />
<br />
1. Create a Bitmap<br />
2. Lock a rectangular portion of this bitmap and provide a temporary buffer <br />
via the LockBits method<br />
3. Copy the memory from DIB<br />
4. Unlock the Bitmap<br />
<br />
-- Microsoft Pseudo-Tech Support
I've read about 20 posts on how to create a Bitmap from the old traditional DIB and they always say about the same thing. My application is trying to convert a Twain DIB to a bitmap without saving/loading the image.
And you were right about the ReadOnly flag. I hadn't gotten it to compile enough to test it.
A lot of people are apparently having the same issue with the TWAIN support. .NET Twain Image Scanner
|
|
|
|
|
Sounds to me like you want to use the InteropServices and DllImport the CopyMemory function (from Kernel32.dll I think).
John :D
|
|
|
|
|
DOH!!! I am so nearsighted on the issue, I keep forgetting you can access the API directly.
I was so concentrating on trying to get Marshal to work since it has like 28 friggin overrides.
Thanks John!
|
|
|
|
|
John Fisher wrote:
Sounds to me like you want to use the InteropServices and DllImport the CopyMemory function (from Kernel32.dll I think).
Grr, I was just gonna sugest that! But his reply gave me a hunch to fix a small problem I have had for a long time
Cheers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
Well, if it makes you feel any better leppie, no success yet.
On the 'CopyMemory' step, getting 'object reference not set to an instance of an object' and no clues atm.
[DllImport("kernel32.dll", EntryPoint="RtlMoveMemory")]<br />
internal static extern void CopyMemory( IntPtr Destination, IntPtr Source, int Length );<br />
<br />
.....<br />
<br />
Rectangle rcImage = new Rectangle( 0, 0, iWidth, iHeight );<br />
<br />
m_CurrentImage = new Bitmap( iWidth, iHeight, PixelFormat.Format8bppIndexed );<br />
<br />
BitmapData pBitmapData = m_CurrentImage.LockBits( rcImage, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed );<br />
<br />
CopyMemory( pBitmapData.Scan0, hDibBitmap, iWidth * iHeight );<br />
<br />
m_CurrentImage.UnlockBits( pBitmapData );
|
|
|
|
|
Finally have some success. Thanks guys!!
I just needed to Lock my source pointer and it's working 'ok' at this time. Still gotta flip the memory upside down and ignore the headers.
|
|
|
|
|
I have a Web Service that I've created called CreditSearch. This Web Service has a single exposed method called Search that returns the requested individual's credit in an XML-formatted string. I then have an ASPX client that calls accepts an SSN as input, calls the service's Search method and displays the results. So far, very easy.
However, I think I'm doing some steps incorrectly. What I do is build the service, run the wsdl utility to create a .cs file, copy that .cs file into the client's project and then run the client. Is this correct?
It seems that I'm supposed to - instead of manually callnig wsdl - select the Add Web Reference menu option and have it do the work for me. However, when I do that, the client code no longer builds. What am I doing wrong here?
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
|
|
|
|
|
Tom Archer wrote:
It seems that I'm supposed to - instead of manually callnig wsdl - select the Add Web Reference menu option and have it do the work for me. However, when I do that, the client code no longer builds. What am I doing wrong here?
Did you add "using statement" to the client code?
After we add Web reference, we must add using statement by hand.
For example, using servicename.host_name.
"using Search.localhost".
Please, don't send me your email about your programming questions directly.
However, if you believe that you gives me some benefits, you can send me your email.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
If only it were that simple. For some reason, the reference file being generated contains an empty class with its public members not showing up.
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
|
|
|
|
|
I found the problem. Properties that are to be exposed by marshalled objects cannot be read-only or they won't be exposed via the WSDL. This is because of some lame rule that the serializer imposes. Get this, though. The set method can be blank meaning that we're forced to include a method that does absolutely nothing in order to make the compiler happy
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
|
|
|
|
|
I came across the same problem today with the XMLSerialiser... But in an attempt to deserialise the object (in my case quite complex) failed...
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
1. (The probably ridiculous question Can a Panel be on one thread, and it's parent Form be on another?
2. I want my app to have two threads- main and worker. How do I stop the worker thread from ending while its waiting for stuff to do? Do I actually have to make some kind of hackish while(true) loop while it's waiting for something to do. If I do that, and then the main Thread calls one of the workers's functions via a delegate, then how do I make it escape the while loop to do it's work?
I mean, the main thread in a normal app doesn't need anything like that in it, it just stays alive waiting for events until the user exits the app. Its not like we do void Main{while(true) listenforevents();} you what I mean? Is there a Thread.ListenForEvents=true so that it won't die?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|