How can I tint one color with another color? i.e. say i have a Color.LightSkyB lue
(135,206,250) i want to tint it with Color.Green(0,1 28, 0)
Whats the math behind it?
6 3164
How can I tint one color with another color? i.e. say i have a Color.LightSkyB lue
(135,206,250) i want to tint it with Color.Green(0,1 28, 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.ColorMa trix
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;
-
}
Plater 7,872
Recognized Expert Expert
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 name byte4. I have
written the following code:
First, thePanorama is defined as:
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Then I loop through like follows:
|
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 open a secured Access
application and then open a form and find a record. (The Access App is
secured not with a database password but with full user name and password
security.)
I can open the form and find the record OK. I am having problems...
|
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. Together we
put together an application we both think is of value.
The app is written. Of course, the app is not finished. I suppose I
could work on this app for the rest of my days adding new features and
enhancing and adjusting as new...
|
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 own web site (i.e. IP, root folder, etc.). Each accesses it's
own SQL Server 2000 database. Let's call them App A and App B.
If I open a page in App A that starts a long-running process...so it's
sitting there in perpetual "loading page" state...
|
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
Integrated security is used and anonymous is turned off.)
This app will actually work as a child app for an Intranet app so when I
remove the application designation in IIS for the child app folder,
IsInRole is always null, which is not good. I...
| |
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 like a good idea for the future. I'm
also keen to develop new software in vb.NET as soon as possible.
I will work out how to port the app and how to use ado.NET etc, however I'm
not certain about all the things I need to consider hence the...
|
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.
But when I installed the app from a CD-ROM (Release folder is in D:),
when I remove the app in Control Panel these problems occur:
Control Panel does not delete the application folders.
When I try to delete them I get message "Cannot delete file:...
|
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 app through code? I am using
End
for now. Is there a way I can suppress this exception
message? The app gets invoked programmatically on a
schedule. So no one would be around to click off 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 ):
tint = (tintColor/255.0, tintColor/255.0, tintColor/255.0,
tintColor/255.0)
pix = im.load()
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |