Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Draw a character in two colors

Posted on 2004-10-27
8
Medium Priority
?
250 Views
Last Modified: 2010-04-15
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.
0
Comment
Question by:melodiesoflife
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 12431187
quite a difficult question :)
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12431193
The only solution I can think of is to create an image of the charactor and display it on runtime
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12431277
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 18

Expert Comment

by:armoghan
ID: 12431298
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
 
LVL 6

Author Comment

by:melodiesoflife
ID: 12431611
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
 
LVL 18

Expert Comment

by:armoghan
ID: 12431746
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
 
LVL 7

Accepted Solution

by:
God_Ares earned 300 total points
ID: 12431788
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
 
LVL 7

Expert Comment

by:God_Ares
ID: 12431791
pb is an imagebox ,, uses system.drawing,drawing2d;
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question