Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 312119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:59:13+00:00 2026-05-12T07:59:13+00:00

I’m making a simple image editor in VB.NET, and one of the functions is

  • 0

I’m making a simple image editor in VB.NET, and one of the functions is brightness/ exposure.

this is how I’m doing it:

For i = 0 To img.Width - 1
    For j = 0 To img.Height - 1
        Dim s As Color = img.GetPixel(i, j)

        Dim r As Integer = s.R * 2
        Dim g As Integer = s.G * 2
        Dim b As Integer = s.B * 2
        If s.R * 2 > 255 Then
            r = 255
        End If

        If s.G * 2 > 255 Then
            g = 255
        End If
        If s.B * 2 > 255 Then
            b = 255
        End If
        Dim x As Color = Color.FromArgb(255, r, g, b)
        img.SetPixel(i, j, x)

    Next
Next

where 2 is brightness which makes it twice as bright.

Only problem is this doesnt seem to work well because it does it, but takes about 30 seconds!
What am I doing wrong? is there a better way to implement it?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:59:13+00:00Added an answer on May 12, 2026 at 7:59 am

    You can use a ColorMatrix and ImageAttributes to do it a lot faster. Here’s how:

    Imports System.Drawing.Imaging
    
    Public Class Form1
    
    Dim g As Graphics
    Dim img As Image
    Dim r As Rectangle
    
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      ' load photo file into picture box and initialize graphics
      img = Image.FromFile("c:\tmp.jpg")
      PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height, PixelFormat.Format32bppArgb)
      g = Graphics.FromImage(PictureBox1.Image)
      r = New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height)
      g.DrawImage(img, r)
    End Sub
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Call setBrightness(0.2)
    End Sub
    
    Sub setBrightness(ByVal Brightness As Single)
      ' Brightness should be -1 (black) to 0 (neutral) to 1 (white)
    
      Dim colorMatrixVal As Single()() = { _
         New Single() {1, 0, 0, 0, 0}, _
         New Single() {0, 1, 0, 0, 0}, _
         New Single() {0, 0, 1, 0, 0}, _
         New Single() {0, 0, 0, 1, 0}, _
         New Single() {Brightness, Brightness, Brightness, 0, 1}}
    
      Dim colorMatrix As New ColorMatrix(colorMatrixVal)
      Dim ia As New ImageAttributes
    
      ia.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap)
    
      g.DrawImage(img, r, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, ia)
      PictureBox1.Refresh()
    End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.