Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ImageConvert
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaozl
ImageConvert
Commits
11bdbd06
Commit
11bdbd06
authored
Jan 23, 2025
by
zhaozl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: 添加使用ImageReader读取RGBA to NV21图片并保存
parent
b0bdf319
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
ImageRenderer.java
app/src/main/java/tv/yunxi/imgfmt/ImageRenderer.java
+20
-15
No files found.
app/src/main/java/tv/yunxi/imgfmt/ImageRenderer.java
View file @
11bdbd06
...
@@ -196,10 +196,14 @@ public class ImageRenderer implements GLSurfaceView.Renderer {
...
@@ -196,10 +196,14 @@ public class ImageRenderer implements GLSurfaceView.Renderer {
int
pixelStride
=
planes
[
0
].
getPixelStride
();
int
pixelStride
=
planes
[
0
].
getPixelStride
();
int
rowStride
=
planes
[
0
].
getRowStride
();
int
rowStride
=
planes
[
0
].
getRowStride
();
int
rowPadding
=
rowStride
-
pixelStride
*
mWidth
;
int
rowPadding
=
rowStride
-
pixelStride
*
mWidth
;
buffer
.
position
(
RGBA_SIZE
*
5
/
8
);
Log
.
v
(
TAG
,
"acquire image size: "
+
buffer
.
capacity
());
// buffer.position(Y_SIZE / 2);
// buffer.get(mImageBytes, 0, Y_SIZE);
// buffer.position(0);
// buffer.get(mImageBytes, Y_SIZE, Y_SIZE / 2);
buffer
.
position
(
NV21_OFFSET
);
buffer
.
get
(
mImageBytes
);
buffer
.
get
(
mImageBytes
);
// 读取Y数据
// 读取Y数据
// int yOffset = (int)(mHeight * 0.625f);
// int yOffset = (int)(mHeight * 0.625f);
// int yHeight = (int)(mHeight * 0.25f);
// int yHeight = (int)(mHeight * 0.25f);
...
@@ -315,7 +319,8 @@ public class ImageRenderer implements GLSurfaceView.Renderer {
...
@@ -315,7 +319,8 @@ public class ImageRenderer implements GLSurfaceView.Renderer {
GLES20
.
glBindFramebuffer
(
GLES20
.
GL_FRAMEBUFFER
,
0
);
GLES20
.
glBindFramebuffer
(
GLES20
.
GL_FRAMEBUFFER
,
0
);
checkGlError
(
"glBindFramebuffer 0"
);
checkGlError
(
"glBindFramebuffer 0"
);
renderTexture
(
mNV21ToRGBAProgram
,
mFrameTextureID
,
false
);
// 使用NV21ToRGBA的shader
// renderTexture(mNV21ToRGBAProgram, mFrameTextureID, false); // 使用NV21ToRGBA的shader
renderTexture
(
mProgram
,
mTextureID
,
true
);
}
}
private
void
renderTexture
(
int
program
,
int
textureId
,
boolean
toNv21
)
{
private
void
renderTexture
(
int
program
,
int
textureId
,
boolean
toNv21
)
{
...
@@ -514,22 +519,22 @@ public class ImageRenderer implements GLSurfaceView.Renderer {
...
@@ -514,22 +519,22 @@ public class ImageRenderer implements GLSurfaceView.Renderer {
private
static
final
int
VERTICES_DATA_POS_OFFSET
=
0
;
private
static
final
int
VERTICES_DATA_POS_OFFSET
=
0
;
private
static
final
int
VERTICES_DATA_UV_OFFSET
=
3
;
private
static
final
int
VERTICES_DATA_UV_OFFSET
=
3
;
private
final
float
[]
mVerticesData
=
{
// X, Y, Z, U, V
-
1.0f
,
-
1.0f
,
0
,
0
.
f
,
0
.
f
,
// 左下
1.0f
,
-
1.0f
,
0
,
1
.
f
,
0
.
f
,
// 右下
-
1.0f
,
1.0f
,
0
,
0
.
f
,
1
.
f
,
// 左上
1.0f
,
1.0f
,
0
,
1
.
f
,
1
.
f
// 右上
};
// private final float[] mVerticesData = {
// private final float[] mVerticesData = {
// // X, Y, Z, U, V
// // X, Y, Z, U, V
// -1.0f, -1.0f, 0
/* 左下 */, 0.f, 1.f, /* 左上 */
// -1.0f, -1.0f, 0
, 0.f, 0.f, // 左下
// 1.0f, -1.0f, 0
/* 右下 */, 1.f, 1.f, /* 右上 */
// 1.0f, -1.0f, 0
, 1.f, 0.f, // 右下
// -1.0f, 1.0f, 0
/* 左上 */, 0.f, 0.f, /* 左下 */
// -1.0f, 1.0f, 0
, 0.f, 1.f, // 左上
// 1.0f, 1.0f, 0
/* 右上 */, 1.f, 0.f, /* 右下 */
// 1.0f, 1.0f, 0
, 1.f, 1.f // 右上
// };
// };
private
final
float
[]
mVerticesData
=
{
// X, Y, Z, U, V
-
1.0f
,
-
1.0f
,
0
/* 左下 */
,
0
.
f
,
1
.
f
,
/* 左上 */
1.0f
,
-
1.0f
,
0
/* 右下 */
,
1
.
f
,
1
.
f
,
/* 右上 */
-
1.0f
,
1.0f
,
0
/* 左上 */
,
0
.
f
,
0
.
f
,
/* 左下 */
1.0f
,
1.0f
,
0
/* 右上 */
,
1
.
f
,
0
.
f
,
/* 右下 */
};
private
FloatBuffer
mVertices
;
private
FloatBuffer
mVertices
;
private
final
String
mVertexShader
=
private
final
String
mVertexShader
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment