Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2005 VB8.0 VB.NET image
http://stackoverflow.com/questions/3115076/adjust-the-contrast-of-an-image-in-c-sharp-efficiently[^]
 

 
solution for above question is not working in vb 2005
 
i need solution in vb2005
below is vb2005 code
 
Public Shared Function AdjustContrast(Image As Bitmap, Value As Single) As Bitmap
    Value = (100F + Value) / 100F
    Value *= Value
    Dim NewBitmap As Bitmap = DirectCast(Image.Clone(), Bitmap)
    Dim data As BitmapData = NewBitmap.LockBits(New Rectangle(0, 0, NewBitmap.Width, NewBitmap.Height), ImageLockMode.ReadWrite, NewBitmap.PixelFormat)
 
    For y As Integer = 0 To NewBitmap.Height - 1
        Dim row As Pointer(Of Byte) = CType(data.Scan0, Pointer(Of Byte)) + (y * data.Stride)
        Dim columnOffset As Integer = 0
        For x As Integer = 0 To NewBitmap.Width - 1
            Dim B As Byte = row(columnOffset)
            Dim G As Byte = row(columnOffset + 1)
            Dim R As Byte = row(columnOffset + 2)
 
            Dim Red As Single = R / 255F
            Dim Green As Single = G / 255F
            Dim Blue As Single = B / 255F
            Red = (((Red - 0.5F) * Value) + 0.5F) * 255F
            Green = (((Green - 0.5F) * Value) + 0.5F) * 255F
            Blue = (((Blue - 0.5F) * Value) + 0.5F) * 255F
 
            Dim iR As Integer = CInt(Red)
            iR = If(iR > 255, 255, iR)
            iR = If(iR < 0, 0, iR)
            Dim iG As Integer = CInt(Green)
            iG = If(iG > 255, 255, iG)
            iG = If(iG < 0, 0, iG)
            Dim iB As Integer = CInt(Blue)
            iB = If(iB > 255, 255, iB)
            iB = If(iB < 0, 0, iB)
 
            row(columnOffset) = CByte(iB)
            row(columnOffset + 1) = CByte(iG)
            row(columnOffset + 2) = CByte(iR)
 
            columnOffset += 4
        Next
    Next
 
    NewBitmap.UnlockBits(data)
 
    Return NewBitmap
End Function
 
pointer(of byte) gives error
 
pls help
Posted 1-Nov-12 0:53am
Omkaara1.1K
Edited 1-Nov-12 21:53pm
v2
Comments
Sergey Alexandrovich Kryukov at 1-Nov-12 9:55am
   
Not a question. "Not working" is not informative at all. What exactly happens? Did you try to ask the author of the answer?
--SA
ryanb31 at 2-Nov-12 16:38pm
   
And there error is ...?
Omkaara at 22-Nov-12 1:33am
   
yes i did tried above code since im using vb2005 it does not support pointers
Dim row As Pointer(Of Byte) this line gives error
system.refecltion.pointer has no type parameters

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Afzaal Ahmad Zeeshan 256
1 OriginalGriff 251
2 BillWoodruff 240
3 Maciej Los 230
4 Sergey Alexandrovich Kryukov 195
0 OriginalGriff 6,419
1 Sergey Alexandrovich Kryukov 6,008
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,070


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 2 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100