How can I tint one color with another color? i.e. say i have a Color.LightSkyBlue
(135,206,250) i want to tint it with Color.Green(0,128, 0)
Whats the math behind it?
6 3144
How can I tint one color with another color? i.e. say i have a Color.LightSkyBlue
(135,206,250) i want to tint it with Color.Green(0,128, 0)
Whats the math behind it?
Couldn't you just use some application (like Paint.NET) that has a color wheel or mixer, find the color you actually want and then use that RRGGBB value?
Why do you want the program to blend your colors?
Well I had really though I remember seeing something in the Color class about tinting but I can't find it anymore.
Have you read through this? http://www.inform.umd.edu/MCTP/Cours...son/index.html
I was thinking the same. I have found a class that may do it for me.
System.Drawing.Imaging.ColorMatrix
I havent had a chane to tinker with it too much, but it looks like this is gonna work for me. (great reference btw.)
This will do, heres what I came up with: - private Bitmap TintBitmap(ref Bitmap b, Color tintColor)
-
{
-
ImageAttributes ia = new ImageAttributes();
-
float tR = (float)tintColor.R / 255;
-
float tG = (float)tintColor.G / 255;
-
float tB = (float)tintColor.B / 255;
-
-
ColorMatrix cm = new ColorMatrix(new float[][]
-
{
-
new float[] {1, 0, 0, 0, 0},
-
new float[] {0, 1, 0, 0, 0},
-
new float[] {0, 0, 1, 0, 0},
-
new float[] {0, 0, 0, 1, 0},
-
new float[] {tR, tG, tB, 0, 1}
-
});
-
-
ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
-
-
Bitmap result = new Bitmap(b.Width, b.Height);
-
Point[] pts = new Point[] { new Point(0, 0), new Point(b.Width, 0), new Point(0, b.Height) };
-
Rectangle rect = new Rectangle(0, 0, b.Width, b.Height);
-
-
using (Graphics g = Graphics.FromImage((Image)result))
-
{
-
g.DrawImage(b, pts, rect, GraphicsUnit.Pixel, ia);
-
}
-
-
return result;
-
}
Do you need to pass bitmap b in by reference? (Is that just to keep memory usage down for very large bitmap objects?)
Do you need to pass bitmap b in by reference? (Is that just to keep memory usage down for very large bitmap objects?)
Correct, one of my many feeble attempts at minimizing memory consumption.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Patrick |
last post by:
Hello all!
I am using a BufferedImage object to build an image from scratch.
I want it to be a grayscale image with only 8bits of color. I have
the color information as a byte, saved in variable...
|
by: Brad Burke |
last post by:
From a windows .Net app, I need to 1) check if MSAccess is already open to a
certain Access application. If so, then open a form and find a certain
record. 2) If not open, then open MSAccess and...
|
by: Salad |
last post by:
On the computer side of the businees there is me, the developer.
Another person's role is that of the idea man...the person that knows
the business and requirements and issues for the business. ...
|
by: Dave Diehl |
last post by:
Has anyone heard of a problem with a rebuild of one application
causing a problem with another app on the same server?
I have two asp.net applications on the same Win2000 server, each with
it's...
|
by: John Dalberg |
last post by:
I am setting the HttpContext.Current.User in the
Application_AuthenticateRequest event in global.asax.cs. When I use the
IsInRole function in a web page, it works fine. So far so good. (Note that...
|
by: Deano |
last post by:
Hi,
I have a finished Microsoft Access app that we are distributing using an
Access runtime. This works fine (mostly) but I'm sold on the advantages of
dot.NET and upgrading to vb.NET seems...
|
by: George |
last post by:
VB.net 2003 standard, XP windows home edition.
Installed first application OK today.
When I removed the application via Control Panel, there were no
problems and the app folders were deleted.
...
|
by: Ron |
last post by:
my application is throwing an exception error when closing
if I run a procedure in the app. I can't even trap the
error with try/catch ex As Exception. Is there a way to
completely shut down the...
|
by: Dan Moskowitz |
last post by:
Hi,
I'm using PIL to tint and composite images together. Here's how I'm
currently tinting images, it's really slow and I know there's got to
be a better way:
def TintImage( im, tintColor ):...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |