B4A Library BitmapExtended Library

Hey,

Let's give Basic4Android a boost with a new library: BitmapExtended.
With BitmapExtended, you can do a lot more with your bitmaps:

- Resizing, Scaling, Skewing and translating.
- compressing
- createScaledbitmap
- erasing colours
- get density
- change pixels
- Different ways to create bitmaps
- and a lot more!

Everything is explained in the library.
A sample is delivered.

Cheerz,

Tomas
 

Attachments

  • BitmapExtended1.00.zip
    281.2 KB · Views: 3,602

pixelpop

Active Member
Licensed User
Longtime User
Could someone post a code snippet that shows valid parameters for scaleBitmap? I'm not sure what the "degrees" parameters should be.
 

wheretheidivides

Active Member
Licensed User
Longtime User
"Everything is explained in the library. A sample is delivered."

there's not much in instructions here. I tried and failed as usual. Is there any way you could explain is a little better? I have a imageview that are sometimes hor and sometimes vert. I have a thumbnail but would like to them to enlarge and be in correct orientation
 
Last edited:

wheretheidivides

Active Member
Licensed User
Longtime User
Hey,

Let's give Basic4Android a boost with a new library: BitmapExtended.
With BitmapExtended, you can do a lot more with your bitmaps:

Tomas

the attached zip example doesn't do anything. Here's the code.

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   
   Dim btmpex As BitmapExtended
   Dim btmp As Bitmap
   btmp.Initialize(File.DirAssets,"rs2.png")
   

End Sub

Sub Activity_Create(FirstTime As Boolean)

   If FirstTime Then
      btmpex.Initialize("BitmapExtended")
   End If
   

End Sub

Sub Activity_Resume

If File.Exists(File.DirDefaultExternal,"rs2.png") Then
   
Else
   File.Copy(File.DirAssets,"rs2.png",File.DirDefaultExternal,"rs2.png")
End If

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

antreg

Member
Licensed User
Longtime User
Hi!
I have to create an image, using bitmapextender.SetPixels starting from an array of int.
The array of int is a conversion of bytes (one to one, so each value of byte become a int with a java routine written in eclipse)
I am able to obtain a visible image...that is supposed to be a grayscale image, but with a yellow tint and probabily with other problem of saturation.
My question is: with then same values, ina vb.net program on windows I see a perfect and grayscaled, luminosity balanced image, what I'm doing wrong in android world?
 

antreg

Member
Licensed User
Longtime User
HI! I solved. All behaviour depends from bitmap config and how you convert the integer.
For the bitmap config I solved using RGB_565. I create an image directly from a java lib I wrote for converting list of byte in array of int.
For the byte->integer conversion:
B4X:
int gByte = (int) myBytes[i] & 0xFF;
int rgb = (gByte << 16) | (gByte << 8) | gByte;
Where myBytes contains the bytes downloaded from a camera in async way.
 

Firpas

Active Member
Licensed User
Longtime User
How to initialize as mutable a bitmap with config "RGB_565" createed with createbitmap2??

Sub Process_Globals
Dim btmpex As BitmapExtended
...

Sub Activity_Create(FirstTime AsBoolean)
If FirstTime Then btmpex.Initialize("")
...

Sub BtnConvert_Click
Dim Bmp1 AsBitmap = Img1.Bitmap
Dim Bmp2 AsBitmap = btmpex.createBitmap2(Bmp1.Width, Bmp1.Height, "RGB_565")

'This change the config from RGB_565 to ARGB_8888
Bmp2.InitializeMutable(Bmp1.Width, Bmp1.Height)

'Convert to Black and White
For y = 0 To Bmp2.Height-1
For x = 0 To Bmp2.Width-1
If btmpex.getPixel(Bmp1, x, y) >= 0xFFDCDCDC Then
btmpex.setPixel(Bmp2, x, y, Colors.White)
Else
btmpex.setPixel(Bmp2, x, y, Colors.black)
End If
Next
Next
 
Last edited:

Garen Evans

New Member
Licensed User
Longtime User
I am encountering the same problem as Firpas. The following returns a runtime exception to the effect that an Object should first be initialized.


Dim bm3 As Bitmap = bmex.createBitmap2 (256,256,"RGB_565")
Log(bm3.Width & " " & bm3.Height )
 

Devv

Active Member
Licensed User
Longtime User
rotate bitmap is reducing the quality of the image too much !
 

Urishev

Member
Licensed User
Longtime User
I get the bitmap using the camera preview. To work you need a specific part of the bitmap. How to create a new bitmap with the specific coordinates? J use BitmapExtended.createBitmap. Error in the last line. Why?
B4X:
Dim jpeg() As Byte = camEx.PreviewImageToJpeg(PreviewPic, 70)
    lastPreviewSaved = DateTime.Now
    Dim in As InputStream
    in.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
    bmp.Initialize2(in)
    in.Close
      bmp1 = BitmapExtended.createBitmap(bmp, 100, 400, 640, 480, jpeg, false)
 
Last edited:
Top