我正在从我的SD卡中选择一个图像列表和所选的图像,以便以视频格式为用户查看。我不知道该怎么做,有什么想法或链接可供参考。请帮帮我。提前谢谢。
发布于 2015-07-07 20:25:01
@Harini-请关注this link或尝试以下code
try {
File file = this.getFullPath("", "video.mp4");
SequenceEncoder encoder = new SequenceEncoder(file);
// only 5 frames in total
for (int i = 1; i <= 5; i++) {
// getting bitmap from drawable path
int bitmapResId = this.getResources().getIdentifier("image" + i, "drawable", this.getPackageName());
Bitmap bitmap = this.getBitmapFromResources(this.getResources(), bitmapResId);
encoder.encodeNativeFrame(this.pictureFromBitmap(bitmap));
}
encoder.finish();
} catch (IOException e) {
e.printStackTrace();
}
// get full SD path
File getFullPath(String filePatho, String fileName) {
File extBaseDir = Environment.getExternalStorageDirectory();
if (filePatho == null || filePatho.length() == 0 || filePatho.charAt(0) != '/') filePatho = "/" + filePatho;
makeDirectory(filePatho);
File file = new File(extBaseDir.getAbsoluteFile() + filePatho);
return new File(file.getAbsolutePath() + "/" + fileName); // file;
}
// convert from Bitmap to Picture (jcodec native structure)
public Picture pictureFromBitmap(Bitmap src) {
Picture dst = Picture.create((int) src.getWidth(), (int) src.getHeight(), ColorSpace.RGB);
pictureFromBitmap(src, dst);
return dst;
}
public void pictureFromBitmap(Bitmap src, Picture dst) {
int[] dstData = dst.getPlaneData(0);
int[] packed = new int[src.getWidth() * src.getHeight()];
src.getPixels(packed, 0, src.getWidth(), 0, 0, src.getWidth(), src.getHeight());
for (int i = 0, srcOff = 0, dstOff = 0; i < src.getHeight(); i++) {
for (int j = 0; j < src.getWidth(); j++, srcOff++, dstOff += 3) {
int rgb = packed[srcOff];
dstData[dstOff] = (rgb >> 16) & 0xff;
dstData[dstOff + 1] = (rgb >> 8) & 0xff;
dstData[dstOff + 2] = rgb & 0xff;
}
}
} 发布于 2015-07-07 20:22:23
http://wptrafficanalyzer.in/blog/image-slideshow-using-viewflipper-in-android/
希望这能帮助你,或者你可以在android中搜索图片滑块来创建图片幻灯片
https://stackoverflow.com/questions/31268182
复制相似问题