I'm using the following code to convert the matofbyte to base64
Mat img = Imgcodecs.imread(paths.GetValue(0).ToString());
MatOfByte vect = new MatOfByte();
Imgcodecs.imencode(".JPG", img,vect);
string encodedByte = System.Convert.ToBase64String((System.Text.Encoding.ASCII.GetBytes( vect.toArray().ToString())));
However the encoded string is too small through the image size of 1920x1080. Am I doing it right?
Try do not call ToString
on byte[]
.
You convert vect
to byte[]
and then to string, so GetBytes
converts string something like "System.Byte[]".
string encodedByte = System.Convert.ToBase64String((System.Text.Encoding.ASCII.GetBytes( vect.toArray())));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.