1
이미지 선택 도구를 사용하고 서버에서 선택한 이미지를 다운로드하는 Windows 8 프로그램이 있습니다. 서버는 base64string에서 변환 할 이미지가 필요한 API를 제공합니다. 그리고 이미지는 7Mb보다 작아야합니다. 나는 아래의 코드를 사용하고Windows 8의 Base64String
:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
bitmap = new BitmapImage();
byte[] buf;
using (var stream = await file.OpenStreamForReadAsync())
{
buf = ReadToEnd(stream);
}
using (var stream = await file.OpenAsync(FileAccessMode.Read))
{
base64String = Convert.ToBase64String(buf);
bitmap.SetSource(stream);
}
}
그리고 비트 맵 서버로 이동합니다. 하지만 문제가 있습니다. 예를 들어 비트 맵 크기가 jpg 크기보다 훨씬 큽니다. 비트 맵 버전이 7Mb보다 크기 때문에 작은 jpg는 서버로 보내지 않습니다.
이미지를 비트 맵으로 변환하지 않고 base64string으로 변환 할 수 있습니까?