修改cdk-overlay-connected-position-bounding-box的样式
时间: 2023-09-17 10:11:03 浏览: 63
在Angular Material中,`cdk-overlay-connected-position-bounding-box`用于定位和控制浮动面板的位置和大小。要修改其样式,您可以使用全局CSS样式或组件级CSS样式。
如果您希望在全局范围内修改`cdk-overlay-connected-position-bounding-box`的样式,您可以在styles.css文件中添加以下样式:
```css
.cdk-overlay-connected-position-bounding-box {
/* 在此处添加样式 */
}
```
如果您只想在特定组件中修改`cdk-overlay-connected-position-bounding-box`的样式,您可以在组件的CSS文件中添加以下样式:
```css
:host ::ng-deep .cdk-overlay-connected-position-bounding-box {
/* 在此处添加样式 */
}
```
注意,`:host ::ng-deep`是必需的,因为`cdk-overlay-connected-position-bounding-box`是Angular Material内部组件,它不会受到组件样式的影响。
相关问题
:host ::ng-deep .cdk-overlay-connected-position-bounding-box { color: #2d4fff; }不成功
如果您使用的是Angular 9及以上版本,`:host ::ng-deep`已经被弃用了,可以使用`::ng-deep`代替。
另外,修改`cdk-overlay-connected-position-bounding-box`样式时,需要确保样式表优先级高于默认样式,可以使用`!important`来提高优先级。
以下是一个修改`cdk-overlay-connected-position-bounding-box`边框颜色的示例:
```css
::ng-deep .cdk-overlay-connected-position-bounding-box {
border-color: #2d4fff !important;
}
```
注意,`::ng-deep`和`!important`都应该谨慎使用,因为它们可能会对全局样式产生意外的影响。如果可能的话,应该尽量避免使用它们。
如何在chi-cdk下获取到yuv420的图
在chi-cdk中,可以使用MediaCodec类和MediaExtractor类来获取yuv420格式的图像。具体步骤如下:
1. 创建一个MediaExtractor对象并设置要解码的视频文件路径:
```
MediaExtractor extractor = new MediaExtractor();
extractor.setDataSource(filePath);
```
2. 找到包含视频流的轨道:
```
int trackIndex = -1;
for (int i = 0; i < extractor.getTrackCount(); i++) {
MediaFormat format = extractor.getTrackFormat(i);
String mime = format.getString(MediaFormat.KEY_MIME);
if (mime.startsWith("video/")) {
trackIndex = i;
break;
}
}
```
3. 选择并配置要解码的轨道:
```
extractor.selectTrack(trackIndex);
MediaFormat format = extractor.getTrackFormat(trackIndex);
String mime = format.getString(MediaFormat.KEY_MIME);
MediaCodec codec = MediaCodec.createDecoderByType(mime);
codec.configure(format, null, null, 0);
codec.start();
```
4. 循环读取每个视频帧并解码:
```
ByteBuffer[] inputBuffers = codec.getInputBuffers();
ByteBuffer[] outputBuffers = codec.getOutputBuffers();
MediaCodec.BufferInfo info = new MediaCodec.BufferInfo();
boolean isEOS = false;
while (!isEOS) {
int inIndex = codec.dequeueInputBuffer(1000);
if (inIndex >= 0) {
ByteBuffer buffer = inputBuffers[inIndex];
int sampleSize = extractor.readSampleData(buffer, 0);
if (sampleSize < 0) {
codec.queueInputBuffer(inIndex, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
isEOS = true;
} else {
codec.queueInputBuffer(inIndex, 0, sampleSize, extractor.getSampleTime(), 0);
extractor.advance();
}
}
int outIndex = codec.dequeueOutputBuffer(info, 1000);
switch (outIndex) {
case MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED:
outputBuffers = codec.getOutputBuffers();
break;
case MediaCodec.INFO_OUTPUT_FORMAT_CHANGED:
format = codec.getOutputFormat();
break;
case MediaCodec.INFO_TRY_AGAIN_LATER:
break;
default:
ByteBuffer buffer = outputBuffers[outIndex];
// 这里的buffer即为yuv420的图像数据
codec.releaseOutputBuffer(outIndex, true);
break;
}
}
```
通过以上步骤,就可以获取到yuv420格式的图像数据。