android CodecCapabilities 图像格式

A分量为透明度分量,假如这个分量占1bit,可以采用这个分量来设计背景透明的文字或图像, 如果占用多个bit,在可以通过这个bit设置多张图片的重叠效应。

int    COLOR_Format12bitRGB444

每个像素12bit表示,RGB每个分量占4bit

int    COLOR_Format16bitARGB1555

每个像素16bit表示,透明度A占1个bit, RGB每个分量占5bit

int    COLOR_Format16bitARGB4444

每个像素16bit表示,透明度RGB分量,每个分量占用4bit表示

int    COLOR_Format16bitBGR565

每个像素占用16bit, B分量占用5bit, G分量占用6bit, R分量占用5bit

int    COLOR_Format16bitRGB565

每个像素占用16bit, R分量5bit,G分量6bit, B分量5bit

int    COLOR_Format18BitBGR666

每个像素占用18bit, BGA每个分量占6bit

int    COLOR_Format18bitARGB1665

每个像素占用18bit, 其中A占用1bit, R占用6bit, G占用6bit, B占用5bit

int    COLOR_Format18bitRGB666

每个像素占用18bit, RGB每个分量占用6bit

int    COLOR_Format19bitARGB1666

每个像素占用19bit, A分量占用1bit, RGB每个分量占用6bit

int    COLOR_Format24BitABGR6666

每个像素占用24bit, ABGR每个分量占用6bit

int    COLOR_Format24BitARGB6666

每个像素占用24bit, ARGB每个分量占用6bit

int    COLOR_Format24bitARGB1887

每个像素占用24bit, A分量占用1bit, RG每个分量占用8bit, B分量占用7bit

int    COLOR_Format24bitBGR888

每个像素占用24bit, BGR每个分量占用8b it

int    COLOR_Format24bitRGB888

每个像素占用24bit, RGB分量,每个分量占用8bit

int    COLOR_Format25bitARGB1888

每个像素占用25bit, 透明度A占用1bit , RGB每个分量占用8bit

int    COLOR_Format32bitARGB8888

每个像素占用32bit, ARGB每个分量占8bit

int    COLOR_Format32bitBGRA8888

每个像素占用32bit, BGRA每个分量占用8bit

int    COLOR_Format8bitRGB332

每个像素占用8bit, 其中R分量占用3bit, G分量占用3bit, B分量占用2bit

int    COLOR_FormatCbYCrY

前面所提及的图像格式都是RGB三基色格式,而CbCrY是一种YUV信号,可以看成其实YUV信号经过缩放和便宜得到的。其中Y代表亮度信息,Cb,Cr为色度信号,用于描述图像的色彩以及饱和度,Cb为饱和度信息,对应为U, Cr为色度信号对应为V,

int    COLOR_FormatCrYCbY

同样为一种YUV信号,只是亮度,色调,饱和度信息与上述的不同而已。

int    COLOR_FormatL16

 

int    COLOR_FormatL2

                                                                                   

int    COLOR_FormatL24

                                                                                   

int    COLOR_FormatL32

                                                                                   

int    COLOR_FormatL4

                                                                                   

int    COLOR_FormatL8

                                                                                   

int    COLOR_FormatMonochrome

是一种单色图像,具体量化值位数不详

int    COLOR_FormatRawBayer10bit

彩色数码相机需要3个单色的sensor获得RGB分量,但这样成本较高,为了降低成本,在单sensor上通过RGB三色的马赛克滤镜获得颜色分量,这一方法最初由bayer提出,所以取名为bayer, 如下所示,滤镜大概可以有一下四种图案,即GB/RG, GR/BG, BG/GR, RG/GB, 每一个采样点有10 bit ADC进行量化。


int    COLOR_FormatRawBayer8bit

与上面类似,不同在于每个采样点由8bit量化

int    COLOR_FormatRawBayer8bitcompressed

                                                                                   

int    COLOR_FormatSurface

将一个android surface进行mediaCodec编码

int    COLOR_FormatYCbYCr

是一种YUV编码格式

int    COLOR_FormatYCrYCb

一种YUV编码格式

int    COLOR_FormatYUV411PackedPlanar

这是一种紧缩格式,每4个连续的Y分量公用一个UV分量,并且Y分量和UV分量打包到同一个平面 ,和RGB方式类似,如图

 

int    COLOR_FormatYUV411Planar

每4个连续的Y分量公用一个UV分量,但是UV分量打包到不同的平面,如图所示

                                                                                   

int    COLOR_FormatYUV420PackedPlanar

YUV420 packet每2X2像素公用一个UV分量,并且将YUV打包到一个平面,如图所示


int    COLOR_FormatYUV420PackedSemiPlanar

 

int    COLOR_FormatYUV420Planar

每2x2像素公用一个UV空间,Y分量空间后面跟U分量平面,然后为V分量平面,如图

                                                                                   

int    COLOR_FormatYUV420SemiPlanar

每2x2像素公用一个UV空间,这也看成是用隔行UV采样。将UV分量交错打包到一个平面中,如图


int    COLOR_FormatYUV422PackedPlanar

每两个连续的Y分量公用一个UV分量,并且采用紧凑型进行存储

 

int    COLOR_FormatYUV422PackedSemiPlanar

                                                                                   

int    COLOR_FormatYUV422Planar

如下图所示

                                                                                   

int    COLOR_FormatYUV422SemiPlanar


int    COLOR_FormatYUV444Interleaved

表示UV分量没有下采样,换句话,每一个Y分量都有独自的UV分量,如下图所示


int    COLOR_QCOM_FormatYUV420SemiPlanar

                                                                                

int    COLOR_TI_FormatYUV420PackedSemiPlanar

                                                                                    

  • 8
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
要在Android中制作视频动画,您可以按照以下步骤进行操作: 1. 创建一个帧动画资源文件(XML),并在其中定义每一帧所需的图像。例如,您可以在res/drawable目录下创建一个名为“my_animation.xml”的文件,并添加以下内容: ```xml <animation-list android:id="@+id/my_animation" android:oneshot="false"> <item android:drawable="@drawable/frame1" android:duration="100" /> <item android:drawable="@drawable/frame2" android:duration="100" /> <item android:drawable="@drawable/frame3" android:duration="100" /> <!-- 添加更多帧 --> </animation-list> ``` 2. 在您的Activity或Fragment中,加载并启动动画。例如: ```java ImageView imageView = findViewById(R.id.my_image_view); AnimationDrawable animation = (AnimationDrawable) getResources().getDrawable(R.drawable.my_animation); imageView.setImageDrawable(animation); animation.start(); ``` 3. 如果您希望将动画保存为视频文件,则可以使用MediaCodec和MediaMuxer API。首先,您需要创建一个编码器(encoder)和一个多路复用器(muxer),并将它们配置为以所需格式编码和写入视频帧。然后,您可以将每一帧作为位图(Bitmap)传递给编码器,并使用muxer将编码后的数据写入输出文件。最后,您需要在完成处理后释放所有资源。注意:这是一个相对复杂的过程,需要您具有一定的Android编程经验和对视频编码和格式的了解。以下是一个简单的示例代码,供您参考: ```java // 创建编码器(encoder) MediaFormat format = MediaFormat.createVideoFormat("video/avc", width, height); format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate); format.setInteger(MediaFormat.KEY_FRAME_RATE, frameRate); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); MediaCodec encoder = MediaCodec.createEncoderByType("video/avc"); encoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); Surface surface = encoder.createInputSurface(); encoder.start(); // 创建多路复用器(muxer) MediaMuxer muxer = new MediaMuxer(outputFile.getPath(), MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4); // 编码和写入每一帧 Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.frame1); for (int i = 0; i < numFrames; i++) { // 渲染当前帧到编码表面(surfaceCanvas canvas = surface.lockCanvas(null); canvas.drawBitmap(bitmap, 0, 0, null); surface.unlockCanvasAndPost(canvas); // 从编码器输出缓冲区中读取编码后的数据 ByteBuffer[] outputBuffers = encoder.getOutputBuffers(); MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo(); int outputBufferIndex = encoder.dequeueOutputBuffer(bufferInfo, TIMEOUT_US); while (outputBufferIndex >= 0) { ByteBuffer outputBuffer = outputBuffers[outputBufferIndex]; muxer.writeSampleData(videoTrackIndex, outputBuffer, bufferInfo); encoder.releaseOutputBuffer(outputBufferIndex, false); outputBufferIndex = encoder.dequeueOutputBuffer(bufferInfo, TIMEOUT_US); } // 读取下一帧图像 bitmap = BitmapFactory.decodeResource(getResources(), getResources().getIdentifier("frame" + (i+2), "drawable", getPackageName())); } // 释放资源 encoder.stop(); encoder.release(); muxer.stop(); muxer.release(); ``` 希望这些信息对您有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值