473,671 Members | 2,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

brightness adjusting on black & white images vb.net

I'm trying to implement some code in vb.net to allow the user to
adjust the brightness or contrast on an image (through the use of a
slider) that is already black & white in the bitmap. I have tried
to use the colormatrix and even down to the pixel using GetPixel and
SetPixel in system.drawing, but I'm really not up on using gdi+ and
haven't really gotten anywhere. I've seen some examples for VB6, but
I need vb.net.

I know that all the pixels are either 255 or 0 already since its black
and white, but if you are adusting the brightness, how do you decide
which pixels to turn white or black based on how much the user wants
to brighten/darken. I've got code to read & set each pixel, but I
just dont know what to use to decide what to set the new pixel to.

If you someone could post some code or point me to a good example that
explains whats going on, I would be most appreciative.

Thanks,
Mark
Nov 21 '05 #1
7 10837
The GDI+ FAQ has articles on this. Search bobpowell.net for ColorMatrix

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo. com> wrote in message
news:tv******** *************** *********@4ax.c om...
I'm trying to implement some code in vb.net to allow the user to
adjust the brightness or contrast on an image (through the use of a
slider) that is already black & white in the bitmap. I have tried
to use the colormatrix and even down to the pixel using GetPixel and
SetPixel in system.drawing, but I'm really not up on using gdi+ and
haven't really gotten anywhere. I've seen some examples for VB6, but
I need vb.net.

I know that all the pixels are either 255 or 0 already since its black
and white, but if you are adusting the brightness, how do you decide
which pixels to turn white or black based on how much the user wants
to brighten/darken. I've got code to read & set each pixel, but I
just dont know what to use to decide what to set the new pixel to.

If you someone could post some code or point me to a good example that
explains whats going on, I would be most appreciative.

Thanks,
Mark

Nov 21 '05 #2
ma*****@yahoo.c om wrote:
I'm trying to implement some code in vb.net to allow the user to
adjust the brightness or contrast on an image (through the use of a
slider) that is already black & white in the bitmap. I have tried
to use the colormatrix and even down to the pixel using GetPixel and
SetPixel in system.drawing, but I'm really not up on using gdi+ and
haven't really gotten anywhere. I've seen some examples for VB6, but
I need vb.net.

I know that all the pixels are either 255 or 0 already since its black
and white, but if you are adusting the brightness, how do you decide
which pixels to turn white or black based on how much the user wants
to brighten/darken. I've got code to read & set each pixel, but I
just dont know what to use to decide what to set the new pixel to.

If you someone could post some code or point me to a good example that
explains whats going on, I would be most appreciative.

Thanks,
Mark


If your values are at 0 or 255 you've got maximum contrast. You can't
decrease contrast for just a few pixels since there would be no way to
determine what pixels should remain white/black and what pixels should
turn some shade of grey. You could only decrease the contrast by
bringing the 0 and 255 values closer together, but don't expect some
gradient to appear.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #3
So you can use the ColorMatrix to adjust images even if they are
already black and white ?

On Thu, 6 Jan 2005 10:55:00 +0100, "Bob Powell [MVP]"
<bob@_spamkille r_bobpowell.net > wrote:
The GDI+ FAQ has articles on this. Search bobpowell.net for ColorMatrix


Nov 21 '05 #4
Of course. The matrix doesn't care what values the RGB elements are or if
they're the same, which is all a grayscale is, equal R, G and B.

You can still change the brightness and contrast using the matrix. You can't
put saturation back in though. That's like trying to put the air back in a
burst balloon.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo. com> wrote in message
news:f7******** *************** *********@4ax.c om...
So you can use the ColorMatrix to adjust images even if they are
already black and white ?

On Thu, 6 Jan 2005 10:55:00 +0100, "Bob Powell [MVP]"
<bob@_spamkille r_bobpowell.net > wrote:
The GDI+ FAQ has articles on this. Search bobpowell.net for ColorMatrix

Nov 21 '05 #5
Thanks Bob.

I took your example of adjusting the contrast (the one with
ImageContrast as the namespace) and ran against one of my test images.
The problem was the image was able to get darker, but never got any
lighter (even when moving the trackbar all the way over). Let me
explain what I'm doing. The images we display are coming out of a
check scanner for our customers. We allow them to rescan them at
lighter/darker contrast values, but that forces them to go through the
scanner again which is not a real fast device. So what I wanted to do
is let them adjust the original image directly on the screen through
the use of a trackbar and not require them to go through the scanner
again.

The images are coming out of the scanner in a 1bpp indexed pixel format
- black/white ?

Any ideas why it wouldn't get any darker. Is there a better way to do
it.

Many thanks.

Nov 21 '05 #6
I guess the reason is because you're altering the original image, not a copy
of it.

You need to copy the original to the new setting every time, don't change an
image and then try to adjust *its* contrast / brightness later. It's a
classic degradation problem.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo. com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Thanks Bob.

I took your example of adjusting the contrast (the one with
ImageContrast as the namespace) and ran against one of my test images.
The problem was the image was able to get darker, but never got any
lighter (even when moving the trackbar all the way over). Let me
explain what I'm doing. The images we display are coming out of a
check scanner for our customers. We allow them to rescan them at
lighter/darker contrast values, but that forces them to go through the
scanner again which is not a real fast device. So what I wanted to do
is let them adjust the original image directly on the screen through
the use of a trackbar and not require them to go through the scanner
again.

The images are coming out of the scanner in a 1bpp indexed pixel format
- black/white ?

Any ideas why it wouldn't get any darker. Is there a better way to do
it.

Many thanks.

Nov 21 '05 #7
That makes sense. Yea, I am applying the new user settings to the
"already adjusted" image, when I should be going back to the original
each time.

I'll try it when I get in the office. Thanks.
Bob Powell [MVP] wrote:
I guess the reason is because you're altering the original image, not a copy of it.

You need to copy the original to the new setting every time, don't change an image and then try to adjust *its* contrast / brightness later. It's a classic degradation problem.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo. com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Thanks Bob.

I took your example of adjusting the contrast (the one with
ImageContrast as the namespace) and ran against one of my test images. The problem was the image was able to get darker, but never got any
lighter (even when moving the trackbar all the way over). Let me
explain what I'm doing. The images we display are coming out of a
check scanner for our customers. We allow them to rescan them at
lighter/darker contrast values, but that forces them to go through the scanner again which is not a real fast device. So what I wanted to do is let them adjust the original image directly on the screen through the use of a trackbar and not require them to go through the scanner again.

The images are coming out of the scanner in a 1bpp indexed pixel format - black/white ?

Any ideas why it wouldn't get any darker. Is there a better way to do it.

Many thanks.


Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3060
by: Amy | last post by:
Hi, I have written a program using JAI for a project I am doing which can be used to adjust the brightness of an image. It all works fine but I now need to write it all up and am not entirely sure what it is doing. The code is below: public void adjustLight(int ipParam){ // ipParam = 18 pb = new ParameterBlock();
3
7317
by: ACaunter | last post by:
Hi there, I was wondering how i could have a slider bar or something on my ASP.Net page to control the image quality.. like change it's sharpness, brightness, and contrast?? is that possible?? thanks -- AdamPC@hotmail.com
4
8928
by: Greg | last post by:
I'm guessing the problem I'm having has something to do with Master Pages or DetailsView because the exact same code works fine on a page without a Master Page and DetailsView controls. The problem is, when the javascript fires on the txtDateRequiredOut TextBox in IE, I get "Error on Page" in the status bar and the error says: "Object Expected". Viewing the source of the page while running shows a link created properly for the linked...
1
2392
by: Sandy | last post by:
Dear Pythonic People, I recently discovered SciTE (1.68) as a programming editor, and I find it just beautiful. Small, fast, elegant and beautiful. I particularly like syntax highlighting features -- not simply different colours, but styles and fonts too. I don't know whether this is the right place to ask this type of question, but...
1
2353
by: retheeshnewage | last post by:
I have a doubt in php.I wrote a php program to convert colour Images to balck & white.It is working fine with JPEG files and PNG files.When it comes to GIF files I am not getting the colour Image.I think I found the reason of getting error.But I am not able to solve it I am pasting the code which I wrote The reason I think is when I am extracting the RGB value from the image,R and G will be zero everytime.But I am getting the value of...
1
2472
by: Thorsten Kleinweber | last post by:
Hello, I did some first steps in programming a site for a friend and have some questions concerning web design. The site is http://www.stevanez-juls.de: 1. On my tft display (with low brightness adjustment) the site is correctly bright but on some other monitors it's very dark, does somebody know why? 2. Does somebody know why scrolling the white text on black background is deforming the text? If I change the background to a brighter...
3
6009
by: Muddasir | last post by:
hi all i need to upload an image and if that image is coloured i need to convert it to black and white image ... till now i only uploaded images ... simple.. have no idea how to do this (converting) thing.... please help me out .. i just uploaded images so i guess it will be of no use for you people if i put my code here ...
1
15095
by: metaphysics | last post by:
I can't seem to find this anywhere on the web, so I figured I'd post the question here. I'd like to be able to define an image class in CSS to make all posted images black and white. For example, I would use this code if I wanted to change Opcaity of all of them to 50%: img { filter:alpha(opacity=50); -moz-opacity: 0.5; opacity: 0.5; Is their a code in css or javascript that will do something similar, but instead make the images black...
3
3891
by: bmahussain | last post by:
Anybody having javascript coding for adjusting brightness and contrast of an image using slider control. If yes, then kindly forward the same. regards, hussain.
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8819
jinu1996
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...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
tracyyun
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...
1
6222
isladogs
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...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1806
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.