B4A Library [B4X] BitmapCreator Effects

Erel

Administrator
Staff member
Licensed User
Use the source code and add this line to Greyscale:
B4X:
Public Sub GreyScale (bmp As B4XBitmap) As B4XBitmap
    Dim bc As BitmapCreator = CreateBC(bmp)
    Dim argb As ARGBColor
    For x = 0 To bc.mWidth - 1
        For y = 0 To bc.mHeight - 1
            bc.GetARGB(x, y, argb)
            Dim c As Int = argb.r * 0.21 + argb.g * 0.72 + 0.07 * argb.b
            If c < 127 Then c = 0 Else c = 255 '<--------------------------------
            argb.r = c
            argb.g = c
            argb.b = c
            bc.SetARGB(x, y, argb)
        Next
    Next
    Return bc.Bitmap
End Sub
 

Dadaista

Active Member
Licensed User
Hi

There are problems with .BMP files with "profundidad de bits" = 16 maybe "bit depth" in English. The files does not load and crash

the log Says
B4X:
java.lang.IllegalArgumentException: src cannot be null
I Think could be related to Bitmapcreator :rolleyes:

The copy of the project failing is too large for upload. Is here
I Have added two .bmp files. One file with 16 bits and another one with 32 bits

1 bit works
16 bits no works
32 bits works

How it can be solved?

Thx!!
 

Attachments

klaus

Expert
Licensed User
You can do it directly with the BitmapCreator library.
You may have a look at the BitmapCreatorDemo1 program from the B4X Graphics Booklets.
 

ilan

Expert
Licensed User
You can do it directly with the BitmapCreator library.
You may have a look at the BitmapCreatorDemo1 program from the B4X Graphics Booklets.
thanx klaus i will have a look at it.


But this is for a view, i am working with bitmaps. Actually i could load the bitmaps on imageviews and then just change the alpha for that view. This may work. Thanks erel :)
 
Top