B4A Library RoundImage V1.0

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Feb 5, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    RoundImage V1.0

    This Library can create a round image from an bitmap or an round drawable from an drawable

    Code:
    Sub Globals
        
    Dim ri As RoundImage
        
    Private Panel1 As Panel
        
    Private ImageView1 As ImageView
    End Sub
    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("Layout1")
        
    Dim bd As BitmapDrawable
        bd.Initialize(
    LoadBitmap(File.DirAssets,"simonscat.jpg"))
        Panel1.Background = ri.CreateDrawable(bd)
        ImageView1.Bitmap = ri.CreateBitmap(
    LoadBitmap(File.DirAssets,"simonscat.jpg"))
    End Sub

    [​IMG]
     

    Attached Files:

    Schakalaka, JohnC, Procesor and 18 others like this.
  2. NJDude

    NJDude Expert Licensed User

    Nice, if I could download the library :D.
     
    Peter Simpson and DonManfred like this.
  3. DonManfred

    DonManfred Expert Licensed User

    now you can :)
     
  4. NJDude

    NJDude Expert Licensed User

    Cool.
     
  5. itgirl

    itgirl Active Member Licensed User

    amazing one , thanks big time
     
    Peter Simpson likes this.
  6. susu

    susu Well-Known Member Licensed User

    Thank you!
    Can you make the same lib for B4i?
     
  7. DonManfred

    DonManfred Expert Licensed User

    No. I dont know objective c and i even dont have b4i
     
    susu likes this.
  8. ibra939

    ibra939 Active Member Licensed User

    o_O:mad:;)thanks
     
  9. Luiz Fernando Orlandini

    Luiz Fernando Orlandini Active Member Licensed User

    Hey dude

    I got your lib, but I'm afraid that I've found a bug.

    I use lib in different contexts.

    First in my Main Module with an asset image. After that I use the lib from my Utils class code, to renderize my Base 64 images.

    Very good until here.

    But when I create a new Activity and try to use RoundImage lib again, my APP just stop to work without any exception. Can you help me?
     
  10. DonManfred

    DonManfred Expert Licensed User

    Can you upload a small project which shows this issue?
     
  11. Luiz Fernando Orlandini

    Luiz Fernando Orlandini Active Member Licensed User

    Sorry my delay DonManfred. I'll try to do that in the next days.
     
  12. Luiz Fernando Orlandini

    Luiz Fernando Orlandini Active Member Licensed User

    Looking in more details I found the error. I got a Out of memory error, when use many imagens with the lib.
     
  13. Jmu5667

    Jmu5667 Well-Known Member Licensed User

    Awesome !!!!!!!
     
    DonManfred likes this.
  14. Mashiane

    Mashiane Expert Licensed User

    Hi, Don

    How does one put a border around the round image. I want to have a border in another color e.g. grey for example, is that possible. great work..
     
  15. Mashiane

    Mashiane Expert Licensed User

    Is it also possible to make the image oval?
     
  16. DonManfred

    DonManfred Expert Licensed User

    No.

    But maybe it will work with this library if you find a suiteable svg file with an oval.
     
    Mashiane likes this.
  17. anOparator

    anOparator Active Member Licensed User

    Hi to all,
    This is a great library, it loads different file sizes perfectly in the same circle with 1 line:
    Code:
    ImageView1.Bitmap = ri.CreateBitmap(LoadBitmap(File.DirAssets,"simonscat.jpg"))
    .
    but it makes the .jpg too large when used with InputStream.

    Can this lib be used with InputStreams or is there another solution?

    Code:
    Sub ReadBlob
       Cursor1 = SQL1.ExecQuery(
    "SELECT image FROM MyTable WHERE name = name")
       Cursor1.Position = pos

       
    Dim Buffer() As Byte 'declare an empty byte array
       Buffer = Cursor1.GetBlob("Image")
       
    Dim InputStream1 As InputStream
       InputStream1.InitializeFromBytesArray(Buffer, 
    0, Buffer.Length)
      
       
    Dim Bitmap1 As Bitmap
       Bitmap1.Initialize2(InputStream1)
       InputStream1.Close
      
    '   ImageView1.(Bitmap1)                                   '   WAS USING THIS    ***
    '   ImageView1.Bitmap = ri.CreateBitmap(Bitmap1)                         '   PIC TOO LARGE
       ImageView1.SetBackgroundImage = (ri.CreateBitmap,(Bitmap1))   '   ')' expected
       '   Activity.SetBackgroundImage(Bitmap1)
        
    Cursor2 = SQL1.ExecQuery(
    "SELECT name FROM MyTable WHERE name = name")
       Cursor2.Position = pos
       lblImageName.Text = (Cursor2.GetString(
    "Name"))
    End Sub
    Thanks in advance.

    EDIT:

    oops, it does render with InputStream , if the image dimensions are for example 640 x 480 pixels then image Canvas dimensions must be increased until there is a large border around image , maybe 800 x 600 pixels or more.

    The greater the Canvas to Image size ratio the smaller the image shows in ' ri '.
    Thanks again.
     
    Last edited: Nov 22, 2015
  18. DonManfred

    DonManfred Expert Licensed User

    No, the lib does not expose a method to load from an inputstream.
    Save the file from the imputstream to sdcard first
     
    anOparator likes this.
  19. anOparator

    anOparator Active Member Licensed User

    aha ,
    thanks
     
  20. Mashiane

    Mashiane Expert Licensed User

    You might be aware about this, LoadBitmapSample also working perfectly...

    Code:
    img.Bitmap = ri.CreateBitmap(LoadBitmapSample(File.Dirinternal, Application.LabelName & "/" & uf,100%x,100%y))
    Thanks for this brilliance!
     
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