Monodroid에 프로그램을 작성하여 화면에 서명을 캡처 한 다음 jpg 파일로 저장합니다. 서명을 잘 캡처 할 수 있지만 파일을 저장하려고하면 문제가 발생합니다. 사용자가 이미지를 저장하고자 할 때, 아래의 코드가 실행됩니다Monodroid가 jpg에 비트 맵 저장
void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (!m_locked)
{
MemoryStream stream = new MemoryStream();
m_bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
byte[] byteArray = stream.GetBuffer();
//string toSave = Convert.ToBase64String(byteArray);
//save it to file (test);
string path = "/mnt/sdcard/TestSig/";
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
string file = path + "signature.jpg";
FileOutputStream fo = new FileOutputStream(file);
fo.Write(byteArray);
}
}
catch (Exception ex)
{
//display message
}
}
서명이 (활동의 한 OnCreate 방법)하여 설정에 그려진 있다는 이미지 뷰 :
m_imageView = (ImageView)FindViewById(Resource.Id.imageView);
m_imageView.SetBackgroundColor(Android.Graphics.Color.White);
Display d = WindowManager.DefaultDisplay;
m_dw = d.Width;
m_dh = d.Height;
m_bitmap = Bitmap.CreateBitmap((int)m_dw, (int)(m_dh * 0.5), Bitmap.Config.Argb8888);
m_canvas = new Canvas(m_bitmap);
m_paint = new Paint();
m_paint.Color = Color.Black;
m_imageView.SetImageBitmap(m_bitmap);
m_imageView.SetOnTouchListener(this);
문제 이미지 편집기에서 파일을 열면 모든 치수가 정상이지만 완전히 검은 색입니다. 그것은 다음과 비슷한 모습이 될 것입니다
을이 PNG 형식을 사용하는 경우 확인을 작동하는 것 같다 그건 그렇고. Android 기기에 이미지를 저장하고 있지만 Windows PC에서 이미지를보고 있습니다.
감사합니다. m_imageView의 사용자 설정에서
감사합니다. Tom, 치료를 받았습니다! –