HELP => make picture and keept quality !

Hello all,

i have a problem with my app.
This little application make a picture about an client address and a barcode. These information are locate in a parcel
this image is convert into a string and save into a xml file
this xml file is sent to a FTP server
During the nigth a tool runs take all file and place all datas in database...

here is it the method for convert bitmap to a string and string to bitmap

`
public static string ConvertBitmapToString(Bitmap theBitmap)
{
//
string strImage = string.Empty;

        //
        using (var stream = new System.IO.MemoryStream())
        {
            //theBitmap.Compress(Bitmap.CompressFormat.Png, 100, stream);

            //
            var bytes = stream.ToArray();
            strImage = Convert.ToBase64String(bytes);
        }

        //
        return strImage;
    }

    public static Bitmap ConvertStringToBitmap(string theBitmap)
    {
        //
        Bitmap img = null;

        //
        if (theBitmap != null)
        {
            //
            byte[] decodedByte = Android.Util.Base64.Decode(theBitmap, 0);
            img = BitmapFactory.DecodeByteArray(decodedByte, 0, decodedByte.Length);
        }

        //
        return img;
    }

`

as you can see quality (second parameter in method convertBitmapToString is put heigth => 100

but my problem when i get the string into the xml file and used the method ConvertStringToBitmap => the image is not readable ...i see the image but quality is really poor not possible to read the address and os on ...

I've find to solve my problem with google but nothing find ...

Any help would be appreciated ...
thanks

Posts

  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    If you're downloading image from server, why you're converting it into String ?

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭

    Hello @BerayBentesen

    the image is take by an intent , convert to string , place into an xml file and sent to a server.
    the result (xml file) is save into a database

    But me, i must to check the quality of the image because actually it's not ok
    then for to do that i open an xml file copy the string of the image with the method => ConvertStringToBitmap

    but not ok, i can't read the address ...

    any idea ?
    thanks

  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    I would suggest converting bitmap to base64string and than posting to server, which generally used method.

    Also you can set size for Bitmap after choosing / capturing image before converting it into something. For example, 400x400 would be good for testing.

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭

    Hello @BerayBentesen ,

    i see you have some experience with my problem thanks for your answer ...

    but could you post a little sample or a link that can be help me

    thanks for all

Sign In or Register to comment.