B4J Question effect.ColorAdjust

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???
 

Attachments

Erel

Administrator
Staff member
Licensed User


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

B4X:
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, 146, 0.61))
End Sub
 

Attachments

BeneBarros

Active Member
Licensed User
Ok ... Thank you, and congratulations for the prompt service.
I will change the application and return the result here.
 

BeneBarros

Active Member
Licensed User
Ok ... Thank you, and congratulations for the prompt service.
I will change the application and return the result here.
Perfect, it works.

If I do this to include the brightness function, am I doing it right ???
B4X:
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
 
Top