我想通过设置颜色格式使用MediaCodec进行编码COLOR_FormatYUV420Flexible.我的输入缓冲区是yuv420p.当我像这样输入缓冲区时:
int inputBufferIndex = mEncoder.dequeueInputBuffer(-1);
mCurrentBufferIndex = inputBufferIndex;
if (inputBufferIndex >= 0) {
ByteBuffer inputBuffer = inputBuffers[inputBufferIndex];
//if(VERBOSE)
Log.i(TAG,"pos:"+inputBuffer.position()+"\tlimit:"+inputBuffer.limit());
inputBuffer.clear();
return inputBuffer;
}
Run Code Online (Sandbox Code Playgroud)
但有些设备颜色错误.所以我试试这个:
int inputBufferIndex = mEncoder.dequeueInputBuffer(-1);
mCurrentBufferIndex = inputBufferIndex;
if (inputBufferIndex >= 0) {
Image img = mEncoder.getInputImage(inputBufferIndex);
if(img==null)
return null;
//mCurrentInputPlanes = img.getPlanes();
ByteBuffer buffers[]={img.getPlanes()[0].getBuffer(),
img.getPlanes()[1].getBuffer(),
img.getPlanes()[2].getBuffer()};
Run Code Online (Sandbox Code Playgroud)
我将缓冲区填充到YUV通道.它可以在某些设备上运行.但是当调用getInputImage时,moto X pro和huawei P7变为null.文档说图像不包含原始数据.但它也提到COLOR_FormatYUV420Flexible自API 21以来的支持.所以我应该如何解决这个问题.
我正在寻找java(J2SE)中的开源QR码图像生成器组件,但开源许可证不能是GPL许可证(需要包含在一个密切的源项目中).
顺便说一句,我无法从项目访问网络,因此没有Google API.
我想将上传的文件编码为base64,以便我可以将它们传递给请求.问题是我正在使用带有Typescript的Angular 2,但我找不到任何关于如何做到这一点的信息.我发现在Javascript中它可以用canvas完成,但我不知道如何在Typescript中实现代码.
<input type="file" class="form-control" accept="image/*" multiple
[(ngModel)]="spot.images" name="images">
Run Code Online (Sandbox Code Playgroud) 嗨,有一个等效的ruby方法的JavaScript encodeURIComponent方法?我正在使用它URI.unescape(str)但它识别 "£"(在encodeURIComponent它变成之后"%C2%A3")作为"?"标志.任何解决方案?谢谢
我正在尝试用Ruby编码URL并用Javascript解码它们.然而,加号角色给了我奇怪的行为.
在Ruby中:
[Dev]> CGI.escape "a b"
=> "a+b"
[Dev]> CGI.unescape "a+b"
=> "a b"
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.但是Javascript怎么样?
>>> encodeURI("a b")
"a%20b"
>>> decodeURI("a+b")
"a+b"
Run Code Online (Sandbox Code Playgroud)
基本上我需要一种编码/解码URL的方法,这些方法在Javascript和Ruby中的工作方式相同.
编辑: decodeURIComponent不是更好:
>>> encodeURIComponent("a b")
"a%20b"
>>> decodeURIComponent("a+b")
"a+b"
Run Code Online (Sandbox Code Playgroud) 我正在创建一个Windows应用程序,我需要传递一个编码的URL.但我不确定如何在WinForms C#中编码?
我有一个.NET exe文件,我想将其编码为Base-64字符串,然后在稍后使用Powershell从Base64字符串解码为.exe文件.
到目前为止我生成的.exe文件,然而,该文件不能被Windows识别为可以运行的应用程序,并且总是与我传入编码脚本的文件长度不同.
我想我可能在这里使用了错误的编码,但我不确定.
编码脚本:
Function Get-FileName($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = "All files (*.*)| *.*"
$OpenFileDialog.ShowDialog() | Out-Null
$FileName = $OpenFileDialog.filename
$FileName
} #end function Get-FileName
$FileName = Get-FileName
$Data = get-content $FileName
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Data)
$EncodedData = [Convert]::ToBase64String($Bytes)
Run Code Online (Sandbox Code Playgroud)
解码脚本:
$Data = get-content $FileName
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($Data)
$EncodedData = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($Bytes))
$EncodedData | Out-File ( $FileName )
Run Code Online (Sandbox Code Playgroud) 我一直在编写一个Python脚本来解析Soundcloud API中的JSON信息,当我使用json.loads(val)以及如何将JSON信息存储到一个对象时,我只是想知道"u"是什么.美国?
也就是说你为什么这样:
>>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
[u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
Run Code Online (Sandbox Code Playgroud)
请参阅此处的"解码JSON"部分以了解我的意思:
http://docs.python.org/library/json.html
谢谢!
可能重复:
在MySQL数据库中以阿拉伯语保存数据
我在使用PHP从MYSQL数据库中检索阿拉伯数据时出现问题,它显示为问号"????" 在HTML中:
请帮忙 !!!
我在JavaScript中处理utf-8字符串并需要转义它们.
escape()/ unescape()和encodeURI()/ decodeURI()都可以在我的浏览器中使用.
逃逸()
> var hello = "?????"
> var hello_escaped = escape(hello)
> hello_escaped
"%uC548%uB155%uD558%uC138%uC694"
> var hello_unescaped = unescape(hello_escaped)
> hello_unescaped
"?????"
Run Code Online (Sandbox Code Playgroud)
是encodeURI()
> var hello = "?????"
> var hello_encoded = encodeURI(hello)
> hello_encoded
"%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94"
> var hello_decoded = decodeURI(hello_encoded)
> hello_decoded
"?????"
Run Code Online (Sandbox Code Playgroud)
虽然encodeURI()和decodeURI()使用上面的utf-8字符串,但docs(以及函数名称本身)告诉我这些方法适用于URI; 我没有看到任何地方提到的utf-8字符串.
简单地说,对于utf-8字符串使用encodeURI()和decodeURI()是否可以?
encode ×10
javascript ×3
base64 ×2
escaping ×2
ruby ×2
android ×1
angular ×1
arabic ×1
binaryfiles ×1
c# ×1
decode ×1
file ×1
html-encode ×1
java ×1
json ×1
mediacodec ×1
mysql ×1
php ×1
powershell ×1
python ×1
qr-code ×1
typescript ×1
unicode ×1
url ×1
urlencode ×1
utf-8 ×1
winforms ×1