B4J Question effect.ColorAdjust

Discussion in 'B4J Questions' started by BeneBarros, Jun 17, 2019.

  1. BeneBarros

    BeneBarros Active Member Licensed User

    I'm trying to apply an effect to an image but I'm not getting the expected result.
    I posted the image made by Gimp and IcoFx getting good results.
    I also posted the image that I'm trying to apply the same effect for the B4J. but I'm not getting the same result.
    What am I doing wrong???
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    [​IMG]

    BitmapCreatorEffects v1.30 is attached. It includes a new AdjustColors method.

    Code:
    Sub AppStart (Form1 As Form, Args() As String)
       MainForm = Form1
       MainForm.RootPane.LoadLayout(
    "1"'Load the layout file.
       MainForm.Show
       
    Dim bmp As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "orig.png", ImageView1.Width, ImageView1.Height, False)
       ImageView1.SetBitmap(bmp)
       
    Dim effects As BitmapCreatorEffects
       effects.Initialize
       ImageView2.SetBitmap(effects.AdjustColors(bmp, 
    1460.61))
    End Sub
     

    Attached Files:

    BeneBarros and DonManfred like this.
  3. BeneBarros

    BeneBarros Active Member Licensed User

    Ok ... Thank you, and congratulations for the prompt service.
    I will change the application and return the result here.
     
  4. BeneBarros

    BeneBarros Active Member Licensed User

    Perfect, it works.

    If I do this to include the brightness function, am I doing it right ???
    Code:
    Public Sub AdjustColors1(Bmp As B4XBitmap, HueOffset As Int, SaturationFactor As Float, BrightnessFactor As Float) As B4XBitmap
        
    Dim bc As BitmapCreator = CreateBC(Bmp)
        
    Dim hsv As HSVColor
        
    Dim argb As ARGBColor
        
    For y = 0 To bc.mHeight - 1
            
    For x = 0 To bc.mWidth - 1
                bc.GetARGB(x, y, argb)
               
                
    '*****Include
                argb.r = Min(255, argb.r * BrightnessFactor)
                argb.g = 
    Min(255, argb.g * BrightnessFactor)
                argb.b = 
    Min(255, argb.b * BrightnessFactor)
                
    'bc.SetARGB(x, y, argb)
               '****

                ARGBToHSV(argb, hsv)
                hsv.S = hsv.S * SaturationFactor
                hsv.H = (hsv.H + HueOffset) 
    Mod 360
                bc.SetHSV(x, y, hsv.A, hsv.H, hsv.S, hsv.V)
            
    Next
        
    Next
        
    Return bc.Bitmap
        
    'Return bc.Bitmap
    End Sub
     
  5. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice