Draw a character in two colors

Hi all

I want to draw a character in two colors. For example: After display, character "X" has upper part in red and lower part in blue.
How can I do this?

Thanks.
LVL 6
melodiesoflifeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

armoghanCommented:
quite a difficult question :)
0
armoghanCommented:
The only solution I can think of is to create an image of the charactor and display it on runtime
0
armoghanCommented:
Ok another way is to create a custom control whcih has two labels on top of other both should have same text and different color
Now place one label over the other. The label which is on top should have less size so that it becomes half and comes over the other label exectly
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

armoghanCommented:
I made these two labels and set there positions manually

Lower part is blue and the upper part is Black

//
                  // label1
                  //
                  this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
                  this.label1.Location = new System.Drawing.Point(104, 176);
                  this.label1.Name = "label1";
                  this.label1.Size = new System.Drawing.Size(100, 16);
                  this.label1.TabIndex = 2;
                  this.label1.Text = "label1";
                  //
                  // label2
                  //
                  this.label2.Location = new System.Drawing.Point(104, 176);
                  this.label2.Name = "label2";
                  this.label2.Size = new System.Drawing.Size(100, 8);
                  this.label2.TabIndex = 3;
                  this.label2.Text = "label1";
0
melodiesoflifeAuthor Commented:
Hi armoghan
Thanks for your response but do you have any other solution? I hope I can do it by used Graphics, Pen ... classes.

Thanks
0
armoghanCommented:
see if you can use PathGradientBrush or LinearGradientBrush in g.DrawString

http://www.c-sharpcorner.com/2/gdi_plus.asp

I have not done it so do tell me if it works
0
God_AresCommented:
Bitmap texture= new Bitmap(pb.Width,12);
                  Graphics g = Graphics.FromImage(texture);
                  for(int i=0; i<texture.Height;i++)
                  {
                        Pen p  = new Pen(new SolidBrush(Color.FromArgb(255-(int)Math.Round((255.0/texture.Height)*i),0,(int)Math.Round((255.0/texture.Height)*i))),1.0f);
                              
                        g.DrawLine(p,0,i,texture.Width,i);
                        p.Dispose();
                  }
                  g.Dispose();

                  Bitmap b= new Bitmap(pb.Width,pb.Height);
                  g = Graphics.FromImage(b);
                  
                  g.DrawString("he how are you",this.Font,new TextureBrush(texture),0.0f,10.0f);
                  g.Dispose();
                  pb.Image = b;
                  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
God_AresCommented:
pb is an imagebox ,, uses system.drawing,drawing2d;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.