Android Question how to resize image in SignatureTemplate

nickysuwandi

Member
Licensed User
Longtime User
Dear All

How to implement SignatureTemplate.Bitmap.Resize.

i want to resize sign bitmap to 250pixel to 156 pixel,
i had try using this code
bitmap:
SignatureTemplate.Bitmap.Resize(250,156,True )

but image that i save still biggers than this resolution.
(i want to reduce size of file bitmap to 2-5KB)

this my full code
full:
Dialog.ButtonsFont = XUI.CreateFontAwesome(20)
    SignatureTemplate.AddDateAndTime=False
    SignatureTemplate.StrokeWidth =2
    SignatureTemplate.BackgroundColor=Colors.Transparent
    Dim rs As ResumableSub = Dialog.ShowTemplate(SignatureTemplate, Chr(0xF00C), "", Chr(0xF00D))
    Dialog.GetButton(XUI.DialogResponse_Positive).TextColor = XUI.Color_Green
    Dialog.GetButton(XUI.DialogResponse_Cancel).TextColor = XUI.Color_Red
    Dialog.ButtonsFont = XUI.CreateDefaultBoldFont(15) 'return it to the default font. It will no longer affect the current dialog
    Wait For (rs) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        ImageView1.SetBitmap(SignatureTemplate.Bitmap.Resize(ImageView1.Width, ImageView1.Height, True))
        Dim strtmp As String =XUI.DefaultFolder
        Dim strtmpf As String ="sign=202310.png"
        Dim out As OutputStream = File.OpenOutput(strtmp,strtmpf , False)
        SignatureTemplate.Bitmap.Resize(125,60,True )
        SignatureTemplate.Bitmap.WriteToStream(out, 80, "PNG")
        out.Close
        wait for (UploadSignSales(strtmp,strtmpf)) complete (rslt As String)
    End If
 

teddybear

Well-Known Member
Licensed User
Dear All

How to implement SignatureTemplate.Bitmap.Resize.

i want to resize sign bitmap to 250pixel to 156 pixel,
i had try using this code
bitmap:
SignatureTemplate.Bitmap.Resize(250,156,True )

but image that i save still biggers than this resolution.
(i want to reduce size of file bitmap to 2-5KB)

this my full code
full:
Dialog.ButtonsFont = XUI.CreateFontAwesome(20)
    SignatureTemplate.AddDateAndTime=False
    SignatureTemplate.StrokeWidth =2
    SignatureTemplate.BackgroundColor=Colors.Transparent
    Dim rs As ResumableSub = Dialog.ShowTemplate(SignatureTemplate, Chr(0xF00C), "", Chr(0xF00D))
    Dialog.GetButton(XUI.DialogResponse_Positive).TextColor = XUI.Color_Green
    Dialog.GetButton(XUI.DialogResponse_Cancel).TextColor = XUI.Color_Red
    Dialog.ButtonsFont = XUI.CreateDefaultBoldFont(15) 'return it to the default font. It will no longer affect the current dialog
    Wait For (rs) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        ImageView1.SetBitmap(SignatureTemplate.Bitmap.Resize(ImageView1.Width, ImageView1.Height, True))
        Dim strtmp As String =XUI.DefaultFolder
        Dim strtmpf As String ="sign=202310.png"
        Dim out As OutputStream = File.OpenOutput(strtmp,strtmpf , False)
        SignatureTemplate.Bitmap.Resize(125,60,True )
        SignatureTemplate.Bitmap.WriteToStream(out, 80, "PNG")
        out.Close
        wait for (UploadSignSales(strtmp,strtmpf)) complete (rslt As String)
    End If
For WriteToStream to png file, the parameter quality 80 is not effective, try to save as jpg
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
        Dim out As OutputStream = File.OpenOutput(strtmp,strtmpf , False)
        Dim bmp As Bitmap = SignatureTemplate.Bitmap.Resize(125,60,True) 'create new bitmap with the resized version
        bmp.WriteToStream(out, 80, "PNG") ' write this bitmap to the outputstream
        out.Close
 
Upvote 1

nickysuwandi

Member
Licensed User
Longtime User
B4X:
        Dim out As OutputStream = File.OpenOutput(strtmp,strtmpf , False)
        Dim bmp As Bitmap = SignatureTemplate.Bitmap.Resize(125,60,True) 'create new bitmap with the resized version
        bmp.WriteToStream(out, 80, "PNG") ' write this bitmap to the outputstream
        out.Close
thanks DonManfred this want i want
 
Upvote 0
Top