我实现了一个C#应用程序,它以30fps的帧速率接收帧RGB.
使用以下代码管理帧到达事件:
void client_ColorFrameReady(object sender, ColorFrameReadyEventArgs e)
{
mycounter++;
Console.WriteLine("new frame received: " + mycounter);
if (writer != null)
{
count++;
if (count % 2== 0)
{
using (var frame = BitmapImage2Bitmap(e.ColorFrame.BitmapImage))
using (var thumb = ResizeBitmap(frame, 320, 240))
{
writer.WriteVideoFrame(thumb);
}
}
}
else
{
writer.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
使用if条件我只管理两个帧中的一个.
当我的代码调用时,BitmapImage2Bitmap
我获得了这个异常:
英语中的例外应该是:
A first chance exception of type 'System.NotSupportedException' occurred in `PresentationCore.dll`
Additional information: BitmapMetadata is not available on BitmapImage.
Run Code Online (Sandbox Code Playgroud)
奇怪的是,我的应用程序"运行良好",因为帧已正确插入输出文件中.
我已经读过这个,所以问题似乎是WPF框架中的一个错误.
寻找启用CLR集成我找到了这个文档:http://msdn.microsoft.com/en-us/library/ms131048.aspx,它说使用以下代码将"crl enabled"变量设置为1.
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
Run Code Online (Sandbox Code Playgroud)
我想知道如果需要重新启动SQL Server?或者,更具体地说,为了启用CRL集成,要遵循哪些步骤?
sql-server configuration sqlclr sql-server-2008 sql-server-2008-r2
我总是在datetime中使用此代码进行转换:
DECLARE @a datetime
SET @a= CONVERT(datetime,'2012-12-28 14:04:43')
print @a
Run Code Online (Sandbox Code Playgroud)
但这不再适用了!我甚至试过重启SQL Server,但问题仍然存在:
图像中的错误是意大利语.英文应该是:
将char数据类型转换为datetime会导致datetime值超出允许值的范围.
我正在使用Universal Image Loader 1.8.6库来加载从网络上拍摄的动态图像.
的ImageLoaderConfiguration
配置如下:
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.memoryCacheExtraOptions(480, 800) // default = device screen dimensions
.threadPoolSize(3) // default
.threadPriority(Thread.NORM_PRIORITY - 1) // default
.denyCacheImageMultipleSizesInMemory()
.memoryCacheSize(2 * 1024 * 1024)
.memoryCacheSizePercentage(13) // default
.discCacheSize(50 * 1024 * 1024)
.discCacheFileCount(100)
.imageDownloader(new BaseImageDownloader(getApplicationContext())) // default
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
.writeDebugLogs()
.build();
Run Code Online (Sandbox Code Playgroud)
并且DisplayImageOptions
配置是:
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.no_foto)
.showImageForEmptyUri(R.drawable.no_foto)
.showImageOnFail(R.drawable.no_foto)
.build();
Run Code Online (Sandbox Code Playgroud)
我的ArrayAdapter中的getView方法包含以下代码:
iv.setImageResource(R.drawable.no_foto);
imageLoader.displayImage(basePath+immagine, iv);
Run Code Online (Sandbox Code Playgroud)
上面代码的第一行用于避免gridView中的视图回收允许将图像设置在错误的位置(直到图片没有下载).
实际问题是这样的:
如果我打开我的Activity(包含GridView
)所显示的项目,感谢UIL库可以下载图像.(同时no_foto.png
图像显示在网格的每个视图中).当所有视图都加载了自己的图像时,如果我尝试向下滚动然后我回来(向上滚动)我必须等待图像重新加载,因为所有视图现在都被no_foto.png
图像占用.
如何避免重载这些图像?使用Universal …
android android-imageview android-gridview android-view universal-image-loader
可能重复:
从服务启动的Android Toast仅显示一次
我正在使用android.app.Service中定义的Service Android.
我从一个Activity调用此服务(myService).
我的服务是:
public class myService extends Service{
public IBinder onBind(Intent intent){
return null;
}
public void onCreate(){
super.onCreate();
TimerTask task = new TimerTask(){
public void run(){
Log.i("test","service running");
checkDate();
}
};
timer = new Timer();
timer.schedule(task, 0, 20000);
}
public void checkDate(){
Toast toast = Toast.makeText(this, "SIMPLE MESSAGE!", Toast.LENGTH_LONG);
toast.show();
}
}
Run Code Online (Sandbox Code Playgroud)
checkDate()方法驻留在myService类中.
产生的错误是:
09-19 15:41:35.267: E/AndroidRuntime(2026): FATAL EXCEPTION: Timer-0
09-19 15:41:35.267: E/AndroidRuntime(2026): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
09-19 …
Run Code Online (Sandbox Code Playgroud) 我创建了一个Android应用程序,在启动时检查是否有新版本的应用程序.如果是,则应用程序下载新的apk文件并过度安装新的apk.我的应用程序使用sqlite db.但是这个db,从一个版本到另一个版本都可以改变.我想我必须使用这个方法:
onUpgrade()
Run Code Online (Sandbox Code Playgroud)
但我不确切知道如何使用它.
当我启动应用程序时,我将此代码用于克里特数据库(如果不存在):
DbHelper mDHelper = new DbHelper(context, DB_NAME, null, DB_VERSION)
Run Code Online (Sandbox Code Playgroud)
如果我想使用onUpgrade()
方法,我应该改变什么?我什么时候打电话给它?
我尝试了以下SQLite查询:
int idServizo = 150;
String whereClause = id_servizio+" = '"+idServizio+" ' ";
ContentValues cv = new ContentValues();
cv.put("sync", 1);
int r = dbManager.updateTable("myTable", cv, whereClause);
Run Code Online (Sandbox Code Playgroud)
字段sync和id_servizio都是整数.updateTable方法是:
public int updateTable(String table, ContentValues values, String whereClause){
int r = mDb.update(table, values, whereClause, null);
return r;
}
// mDb is SQLiteDatabase object
Run Code Online (Sandbox Code Playgroud)
这一切都很好.但是如果我用rawQuery()方法尝试这个:
public Cursor RawQuery(String sqlQuery, String[] columns){
return mDb.rawQuery(sqlQuery, columns);
}
Run Code Online (Sandbox Code Playgroud)
表格未更新!即使没有发生错误.
int idServizo = 150;
String updateQuery ="UPDATE myTable SET sync = 1 WHERE id_servizio = "+idServizio;
dbManager.RawQuery(updateQuery, null); …
Run Code Online (Sandbox Code Playgroud) 为了将秒数转换为DateTime,在VB .NET中,我使用以下代码:
Dim startDate As New DateTime(1970, 1, 1)
Dim targetDate As DateTime
Dim noOfSeconds As Integer = DataInSeconds
targetDate = startDate.AddSeconds(noOfSeconds)
Run Code Online (Sandbox Code Playgroud)
其中DataInSeconds是一个包含秒数的整数(从1970年1月1日开始)
这很好用.但我不知道如何进行逆转换.(从DateTime到秒数).有人可以帮帮我吗?
我正在修改我的Android应用程序,我在真实设备上尝试它(在eclipse中运行应用程序)并且一切正常.因此,当我对我的更改感到满意时,我打开了Manifest以修改版本以释放它,但是在Manifest中没有任何更改,行发生错误:
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
Run Code Online (Sandbox Code Playgroud)
错误是:
Permission is only granted to system apps
Run Code Online (Sandbox Code Playgroud)
这怎么可能?我用这条线多次构建我的应用程序.
参考上面的链接,我认为Calendar类的getTimeInMillis()返回独立于时区的毫秒数.
但是使用以下代码:
Calendar cal = Calendar.getInstance();
int dateInSeconds = (int)(cal.getTimeInMillis()/1000);
Log.i("TIME IN SECONDS: ",""+dateInSeconds);
Run Code Online (Sandbox Code Playgroud)
首先尝试将我的系统时钟设置为10:00和GMT + 02:00
产生一定的输出数量.但是将系统时钟设置为10:00和GMT + 00:00
输出数量比先前的情况大约7200,相当于约2小时.
为什么?