B4J Question effect.ColorAdjust

BeneBarros

Active Member
Licensed User
Longtime 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

  • B4J.jpg
    B4J.jpg
    113.2 KB · Views: 187
  • Gimp.jpg
    Gimp.jpg
    56.7 KB · Views: 190
  • IcoFx.jpg
    IcoFx.jpg
    36.8 KB · Views: 182
  • orig.png
    orig.png
    2.7 KB · Views: 187

Erel

B4X founder
Staff member
Licensed User
Longtime User
java_RvUhq6yv1J.png


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

  • BitmapCreatorEffects.bas
    11 KB · Views: 190
Upvote 0

BeneBarros

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

BeneBarros

Active Member
Licensed User
Longtime 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
 
Upvote 0
Top