Android Question Create Round Image from Convert btp image

Discussion in 'Android Questions' started by Makumbi, Jun 15, 2019.

Thread Status:
Not open for further replies.
  1. Makumbi

    Makumbi Active Member Licensed User

    This is my image view
    Code:
    ImageView1.SetBackgroundImage(Base64StringToImage(ktb))
    How can i use the codes below to help me create a circle around the converted base64 out put

    Code:
    Sub Base64StringToImage(s As StringAs Bitmap
        
    Dim su As StringUtils
        
    Dim bytes() As Byte = su.DecodeBase64(s)
        
    Dim In As InputStream
        
    In.InitializeFromBytesArray(bytes, 0, bytes.Length)
        
    Dim bmp As Bitmap
        bmp.Initialize2(
    In)
        
    In.Close
        
    Return bmp
    End Sub
    Code:
    Sub CreateRoundBitmap (Input As B4XBitmap, Size As Int) As B4XBitmap
        
    If Input.Width <> Input.Height Then
            
    'if the image is not square then we crop it to be a square.
            Dim l As Int = Min(Input.Width, Input.Height)
            Input = Input.Crop(Input.Width / 
    2 - l / 2, Input.Height / 2 - l / 2, l, l)
        
    End If
        
    Dim c As B4XCanvas
        
    Dim xview As B4XView = xui.CreatePanel("")
        xview.SetLayoutAnimated(
    000, Size, Size)
        c.Initialize(xview)
        
    Dim path As B4XPath
        
    path.InitializeOval(c.TargetRect)
        c.ClipPath(
    path)
        c.DrawBitmap(Input.Resize(Size, Size, 
    False), c.TargetRect)
        c.RemoveClip
        c.DrawCircle(c.TargetRect.CenterX, c.TargetRect.CenterY, c.TargetRect.Width / 
    2 - 2dip, xui.Color_White, False5dip'comment this line to remove the border
        c.Invalidate
        
    Dim res As B4XBitmap = c.CreateBitmap
        c.Release
        
    Return res
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What happens when you run your code?
     
  3. Makumbi

    Makumbi Active Member Licensed User

    When i try to run this code
    Code:
    ImageView1.SetBitmap(CreateRoundBitmap(Base64StringToImage(ktb), ImageView1.Width))
    i get error
    unknown member setbitmap
    below is the converted image
    Code:
    B6convert: Qk321AEAAAAAADYAAAAoAAAAyAAAAJYAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAAubW8/7i3vP+8uL7/vbvA/8C+wv/AvsH/wL/C/8PBxf/Fw8b/xcTG/8fGyP/JyMz/y8rN/8zLzf/OzdD/z83S/9DO0//T0tb/1NPW/9jX2//a2dv/3Nve/+Df4f/m5Ob/5+bo/+fl5//n5ef/6efq/+zp6//s6+3/7ezu/+rm6P/y7/L/8vH0//Du8v/v7vH/7+7y//Dv8//w7/H/7+7y/+/u8v/x8PP/9PP3//Xz+P/08/f/9fT3//Tz9//29fn/+Pf7//j3/P/49/v/+fj8//n4/P/6+f3/+vn9//r5/f/7+v3/+fj8//n4/P/5+Pz/+Pf7//j3+v/t593/8+nS//Tq0v/x5cz/8eTK//Lmyv/4687//e7O//rryf/47Mn/+OvI//rrx//87Mr/+OnE/+vft//g0q3/2s2z/+rex//57NP//fbd//354P/++d///fnd//384f/9/N///fve//363f/9+t3//fjc//322v/999r//ffb//311//99tj//ffY//342P/9+dn//fna//zy1v/58NX//f3o//394v/9/N3//f3f//395P/9/eH//fPS//3uzf/978v/8d2y//Dfu//889P/+OfC//fjvf/2477/9OLF//Xn2P/06OH/8uXb//Lk1//y4dH/8uDL//Hex//x3cP/8t+///Hhxf/679P/+ezM//bkv//y4LX/796x/+/dsv/v3rT/8+bA//311//9/Ob/+vHY//nsz//87s///fHR//3w0P/88dL//fPU//z22P/8/OH//Pzp//387P/9/fP//f32//398v/9/ez//P3n//395f/9+tz/8ubS/+3hxP/v48b/7OHD/+newf/o3cH/6+DD/+zgxv/v5Mj/8+jK//Pnyf/y5Mb/8ePC//Dhvf/u37z/7N66/+vdvP/s377/6+DD//DlyP/x58z/8OXP/+3k0P/l39P/3NrX/+no6f/v7fP/8O/z/+/u8v/u7fL/7uzx/+zr8P/r6e7/6unu/+jo7v/m5u3/pq3d/3ea1P9zmtT/bJbR/3Ca1/9wmtf/bZPS/2mU0/+4tbz/ura7/7y4vf++usD/wL3B/8G/w//DwcX/xcPH/8fGyf/Jxsr/ysjL/8vKy//My83/zs3P/8/O0f/Qz9H/1NPW/9jX2f/Z2dr/3Nvd/9zb3v/e3N//5OPl/+Xl5v/o5+n/6Ofo/+jn6v/r6uz/7ezv/+3s7//u7fD/6+jq//b19//y8fT/8fDz//Lx9f/y8fX/8/L1//Py9f/z8vb/8/L2//Lx9P/z8vb/8/L2//X0+P/19Pj/9fT3//X09//29fj/9vT5//f2+v/49/v/+vj8//r5/f/7+v3/+/r8//v6/f/7+vz/+/r9//n4/P/49/z/+Pf6/+3o4P/v5M7/8OTN/+7iyP/v48j/9OfL//zw0v/98dH/+uvK//XmxP/46sn/++zI//vsyf/158L/59mz/9zMqf/d0Lf/7uHK//zy2f/9++D//fzj//774f/++9///f3i//394v/9/OD//vze//373v/9+t3//fnc//z42//9+dv//fXY//332f/99tf//PjX//372f/9+9r//PXX//rw1P/8/ej//f3j//373P/9/d///f3i//v20//x4Lj/7dy0/+nWrf/o0af/7924//HiwP/x4ML/8+XU//fw7P/8+fn//v7+/+bm7v/39/r/7O7z//3+///7+/3///7+//37/P/48/T/+fPw//358P/9+Of/+e3S/+7ctv/v3a//7tyv/+zasP/s2rT/9evK//384//8+N//8+jR//fqz//568///O7R//301P/9+tv//v3j//396v/8/Oz//fz0//39+//9/fP//f3u//z86P/9/Of//f3l//353f/05tH/8eXH/+/jx//p3cD/59u+/+jdwf/t4sX/8ebJ//DmyP/y58r/8+jK//PmyP/y48P/7+C9/+7fvP/t3rv/7N6+/+vfv//u48b/7+XK//Dny//v5s7/7eTQ/+Xf1f/g3dv/7ezv//Dv9P/w8PT/7+7z/+7t8v/u7PL/7Ovx/+vq8P/r6u//6env/+rp8P+tt+T/fKDa/3id1/94ndj/b5bU/2uS0P9rkNH/a5HR/7y6vf++vL//v7zA/8C9wP/Bv8T/wsHE/8XDx//Hxsj/ysjK/8vIzP/Mycz/zcvN/87Mzv/QztH/0M7T/9HP0//V1Nf/2NfZ/9rZ3f/c293/3dze/+Lh4//k4+b/5eTm/+fm5//l5Ob/6Ofp/+vq7P/s6+3/7uvv//Lw8//v6uz/9vT2//Hw8//w7/H/8O/y//Px9f/08/b/9fT3//X0+P/19Pf/9PP2//Tz9//18/n/9fT4//X0+P/19Pj/9fT5//b0+f/39fr/+Pb7//n4/P/6+fz/+vn9//r5/P/6+f3/+/r9//r5/P/6+f3/+fj8//r4/P/5+Pz/8Ovm/+zizP/r4Mn/7eLH/+3hxv/y5cj//O/P//3wz//9783/9ufF//bnxv/77Mn/++zJ//Djv//j1rL/3c+s/9/Ru//z587//fjf//385f/9/ej//f3j//374f/9/eT//f3i//394f/9/eD//fzg//773//9+d3//Pnc//352//99Nb//fbX//342P/899b//frZ//372P/89Nb/+vDU//396P/8/eX//fzd//383P/58c3/8d+2/+rWrP/m0qX/5tGl/+fRrP/q2cT/8+rk//z5+f//////7evv/+Ti5f/a2N7/qaSz//n4+/+claT/7uzy/7eywP//////ysvR/+Tl6v/w8Pb/+fr8///////++/v/9e3s/+3f2//l1cP/6NW0/+3ct//y4b3/9+vL//384v/9+N///fbX//v11P/9+Nb//frZ//383v/9/ef//fzv//79+f/+/vv//f3x//z97P/8/On//fzn//386P/9/eT//fne//Pm0P/05sr/8+bL//HkyP/r4ML/6N3A/+rfwv/w5cj/8ebK//Poy//06cz/8ubJ//Hjw//v4L7/7uC9/+7evf/t4L//7uLD/+/kx//x58v/8ejN//Dn0P/u5dP/497V/+Tj4v/v7vH/8fD1//Hw9f/w7/T/7+70/+7t8v/t7PH/7Ozx/+vr8P/r6+//6env/6+04f9+n9n/dpzW/3Ka2P91ndf/b5jW/26T1f9pktL/wL3C/7++wv/BvsL/wb/C/8LBxP/DwcT/xsTH/8nIyv/Lyc3/zMnM/8zKzf/Pzc//0M7S/9DP0f/S0NP/1NLW/9fW2P/Z2Nr/2tnc/9zb3f/d293/4d/h/+Tj5f/l5Ob/5eTn/+bl5//o5+n/6ejq/+vq7P/w7vL/8/H0//Ds7v/z8vT/8O/y/+/u8f/v7vL/7+7y//Dv8v/y8fT/9fT3//b1+P/29fj/9fT4//X09//19Pf/9PP2//Py9v/z8vb/9PP3//X09//29fn/9vX5//f2+v/5+Pz/+vn8//v6/f/7+v3/+/r9//v6/f/7+v3/+/r9//r5/P/z7+v/6+HL/+fdxP/n28H/59rA//Llyf/88dL//fHR//ztzf/87c3/+erJ//ztyv/668j/7uG8/+HUrf/XyKb/4dS+//nv1//9/OP//fzm//396P/9/eT//fzi//394v/9/eL//f3h//394f/9/N///fzf//384P/9+9///fvf//342//9+Nn//fjY//321v/+99X//fjW//v01f/58Nb//f3p//396P/+/N7/+O/K//Lgtv/v3bP/6tWo/+XRrv/p2s3/9O3s//78/f//////19Pc//7+/v/UztX/wbrJ/5eLo//i3+f/9/X4/6GXo//o5ev/ubO+/9DM0/+glaP/19LY/765x//m5ev//////83O2//+/v////////7+/v/38vX/7+Xh/+/gzv/04sP/9ujI//353P/889n/9+nQ//rvzf/9+tr//f3l//387v/
     
  4. Makumbi

    Makumbi Active Member Licensed User

    When i try to run this code
    Code:
    ImageView1.SetBitmap(CreateRoundBitmap(Base64StringToImage(ktb), ImageView1.Width))
    i get error
    unknown member setbitmap
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    How could we know that this is the problem based on your question? I actually read every line of your code trying to understand the problem. It is your job to provide the relevant information.
     
Thread Status:
Not open for further replies.
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