public void sendDocument(Peer peer, String fullFilePath, String fileName) { int dot = fileName.indexOf('.'); String mimeType = null; if (dot >= 0) { String ext = fileName.substring(dot + 1); mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext); } if (mimeType == null) { mimeType = "application/octet-stream"; } Bitmap fastThumb = ImageHelper.loadOptimizedHQ(fullFilePath); if (fastThumb != null) { fastThumb = ImageHelper.scaleFit(fastThumb, 90, 90); byte[] fastThumbData = ImageHelper.save(fastThumb); sendDocument( peer, fileName, mimeType, new FastThumb(fastThumb.getWidth(), fastThumb.getHeight(), fastThumbData), fullFilePath); } else { sendDocument(peer, fileName, mimeType, fullFilePath); } }
public void sendPhoto(Peer peer, String fullFilePath, String fileName) { try { Bitmap bmp = ImageHelper.loadOptimizedHQ(fullFilePath); if (bmp == null) { return; } Bitmap fastThumb = ImageHelper.scaleFit(bmp, 90, 90); String resultFileName = getExternalTempFile("image", "jpg"); if (resultFileName == null) { return; } ImageHelper.save(bmp, resultFileName); byte[] fastThumbData = ImageHelper.save(fastThumb); sendPhoto( peer, fileName, bmp.getWidth(), bmp.getHeight(), new FastThumb(fastThumb.getWidth(), fastThumb.getHeight(), fastThumbData), resultFileName); } catch (Throwable t) { t.printStackTrace(); } }
@Override public void changeMyAvatar(String descriptor) { try { Bitmap bmp = ImageHelper.loadOptimizedHQ(descriptor); if (bmp == null) { return; } String resultFileName = getExternalTempFile("image", "jpg"); if (resultFileName == null) { return; } ImageHelper.save(bmp, resultFileName); super.changeMyAvatar(resultFileName); } catch (IOException e) { e.printStackTrace(); } }