|
Hi,
I would like to stream the desktop image of one computer to another, over the internet. My idea is to do a screen capture at regular intervals, and send it to the receiver.
In order to reduce network load, I would like to compress each frame in function of the previous one (i.e., only the parts of the picture that have changed between two successive frames should be sent, and those parts are compressed before sending).
I suppose there must be an easy way (e.g., using a codec) to do this, but I can't seem to find it on the web/forums.
Can anyone help me out?
Thanks !
ZeJibe
|
|
|
|
|
There are no easy ways, you have to calc the diff of 2 images yourself.
|
|
|
|
|
Hi,
how i can validate a formula.
Formula contains columns of table and operators.
if suppose c1,c2,c3 are columns of table, c1 is of type string, cs is decimal and c3 is int.
formula may be a+(b*c),or a*(b/c)
lakshmi
|
|
|
|
|
c1 needs to be turned into a number, with int.TryParse or double.TryParse. Then it will just work. Otherwise, it's not possible.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
why DataView.RowFilter is more solwer than DataTable.Select function?
using the following code to test.
class Program
{
const int ROWS_COUNT = 50; // 设置处理数据大小。 单位:w 万
const int ROWS_COUNT_UNIT = 10000; // 数据行单位:万
const double ROWS_TOTAL_COUNT = ROWS_COUNT * ROWS_COUNT_UNIT; // 总循环次数
const double ROWS_SHOW_INFO_LINE = ROWS_TOTAL_COUNT / 10; // 显示进度
private static string SAVE_FILE_NAME = string.Format("{0}w_{1}", ROWS_COUNT.ToString(), DateTime.Now.ToString("yyyyMMddhhmmss"));
private static StringBuilder builder = new StringBuilder(string.Format("ROWS COUNT :{0}w\n", ROWS_COUNT));
private static DataTable mDataTable = null;
private static DataView dv = null;
private static string str = string.Empty;
static void Main(string[] args)
{
// 添加数据行
DateTime start = DateTime.Now;
AddData();
str = string.Format("cost [ {0} ms ] to add [ {1}w ] rows.\n{2}\n",
(DateTime.Now.Subtract(start).TotalMilliseconds.ToString()),
ROWS_COUNT.ToString(),
"----- AddData() END -----\n");
Console.WriteLine(str);
builder.AppendFormat(str);
// 添加 DataTable 的主键
start = DateTime.Now;
AddPrimaryKey(true);
str = string.Format("cost [ {0} ms ] to AddPrimaryKey().\n{1}\n",
(DateTime.Now.Subtract(start).TotalMilliseconds.ToString()),
"----- AddPrimaryKey() END -----\n");
Console.WriteLine(str);
builder.AppendFormat(str);
// 循环进行 10 次数据过滤测试
start = DateTime.Now;
int times = 0;
string enter = string.Empty;
while ((++times) < 11)
{
str = string.Format("running {0} times ...\n", times.ToString());
Console.BackgroundColor = ConsoleColor.Red;
Console.WriteLine(str);
Console.ResetColor();
builder.AppendFormat(str);
Test();
builder.Append("\n\n");
}
str = string.Format("\ncost [ {0} ms ] to WHILE loop.\n",
(DateTime.Now.Subtract(start).TotalMilliseconds.ToString()));
Console.WriteLine(str);
builder.AppendFormat(str);
// 测试结果输入到 文件中
WriteToFile(builder.ToString());
// 提示用户操作
Console.WriteLine("Press any key to continue ...");
Console.ReadLine();
}
///
/// 创建dataTable
///
private static void AddData()
{
Console.WriteLine("Adding data ... ");
mDataTable = null;
mDataTable = new DataTable("test");
DataColumn dc = new DataColumn("index", typeof(double));
dc.DefaultValue = 3000;
mDataTable.Columns.Add(dc);
mDataTable.Columns.Add(new DataColumn("content", typeof(string)));
DateTime start = DateTime.Now;
TimeSpan end;
double rowsCount = ROWS_TOTAL_COUNT + 1;
DataRow row = null;
for (int i = 1; i < rowsCount; i++)
{
if (0 == (i % ROWS_SHOW_INFO_LINE))
{
end = DateTime.Now.Subtract(start);
str = string.Format("Readed {0} rows [ {1} ms]...\n\n", i.ToString(), end.TotalMilliseconds.ToString());
Console.WriteLine(str);
builder.AppendFormat(str);
start = DateTime.Now;
}
// 1000w 数据时,出现了 SystemOutOfMemory 的异常
row = mDataTable.NewRow();
//row["index"] = i;
row["content"] = i.ToString();
mDataTable.Rows.Add(row);
}
mDataTable.AcceptChanges();
Console.Clear();
}
///
/// 添加主键值
///
/// <param name="add" />
private static void AddPrimaryKey(bool add)
{
Console.WriteLine("Adding Primarykey ...");
DateTime start;
if (add)
{
// add PrimaryKey columns
int key = mDataTable.PrimaryKey.Length;
DataColumn[] dcs = new DataColumn[key + 2];
dcs[key + 0] = mDataTable.Columns["index"];
dcs[key + 1] = mDataTable.Columns["content"];
start = DateTime.Now;
mDataTable.PrimaryKey = dcs;
str = string.Format("cost [ {0} ms ] mDataTable.PrimaryKey...\n", (DateTime.Now.Subtract(start).TotalMilliseconds.ToString()));
Console.WriteLine(str);
builder.AppendFormat(str);
}
start = DateTime.Now;
dv = null;
dv = mDataTable.DefaultView;
str = string.Format("cost [ {0} ms ] mDataTable.DefaultView...\n", (DateTime.Now.Subtract(start).TotalMilliseconds.ToString()));
Console.WriteLine(str);
builder.AppendFormat(str);
builder.Append("PrimaryKey Columns Details;\n");
foreach (DataColumn dc in mDataTable.PrimaryKey)
{
builder.AppendFormat("Column Name: \t{0}\nColumn DataType: \t{1}\n", dc.ColumnName, dc.DataType.Name);
}
}
///
/// 数据筛选测试
///
private static void Test()
{
const string CONDITIONS_1 = "index < 80000";
const string CONDITIONS_2 = "index < 80000 or (content LIKE '%200%')";
SelectFromDatatable(CONDITIONS_1);
SelectFromDatatable(CONDITIONS_2);
FilterDataView(CONDITIONS_1);
FilterDataView(CONDITIONS_2);
}
///
/// 将结果记录到文件
///
/// <param name="content" /><文件内容/param>
private static void WriteToFile(string content)
{
try
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(string.Format("{0}.txt", SAVE_FILE_NAME), false, Encoding.UTF8);
sw.Write(content);
sw.Close();
sw = null;
}
catch (Exception exp)
{
System.Diagnostics.Debug.WriteLine(exp.Message);
}
}
///
/// 通过DataTabl.Select 过滤数据
///
/// <param name="condtions" />
private static void SelectFromDatatable(string condtions)
{
DateTime start = DateTime.Now;
start = DateTime.Now;
mDataTable.Select(condtions);
builder.AppendFormat("mDataTable.Select(\"{0}\"):\n\t{1} ms\n", condtions, (DateTime.Now.Subtract(start).TotalMilliseconds.ToString()));
}
///
/// 通过 DataTable.DefaultView.RowFilter 过滤数据
///
/// <param name="conditions" />
private static void FilterDataView(string conditions)
{
DateTime start = DateTime.Now;
start = DateTime.Now;
dv.RowFilter = conditions;
builder.AppendFormat("dv.RowFilter = \"{0}\": \n\t{1} ms\n", conditions, (DateTime.Now.Subtract(start).TotalMilliseconds.ToString()));
}
}
宝剑锋从磨砺出,梅花香自苦寒来
我欲仗剑走天涯
|
|
|
|
|
hi
i am new in c#.net.
i want to move among some records in database
for example go to the first record,last record,next record,previus record
please help me.
somi
|
|
|
|
|
1 - don't use your email as a username, it will get you spam
2 - there are tons of articles on the web on this, you should also buy a book and work through it, if you're new to C++.
All you need to do is store a number to represent the index of the record you want to read, and use that to read a record when a button is pressed.
I answered this same question the other day, worded exactly the same. Was it you ? If so, the reason you didn't understand my answer, is that you need to learn some basics first.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: I answered this same question the other day, worded exactly the same.
Then its valid to just post the same response, but you should at least have replaced C++ with C# in this forum .
Robert
|
|
|
|
|
Hi Guys,
I'm trying to get into XNA v1.0 (..last time I touched it was Beta 1.) ...So, I'm building myself a terrain loader. Trying to get my Terrain class set up so that it can be given a heightmap file and it can initialize the size of the data array based upon the width & height of the file that is passed to it. Does anyone know of a way(preferrably a simple way) of accepting the path of a jpeg and getting the width and height out of the FileInfo?(I'm making an assumption that is where it is located, but I do not know for a fact)
Welcome my son...Welcome..to the Machine
|
|
|
|
|
System.Drawing.Image.FromFile(jpegpath).Size
Mazy
"This chancy chancy chancy world."
|
|
|
|
|
Thanks for your help, but there is no System.Drawing namespace in the XNA Framework(System.Drawing is the wrapper around the GDI). Does anybody know of a method that doesn't use the GDI+?
Welcome my son...Welcome..to the Machine
|
|
|
|
|
 Hi, the only way to get JPEG size without using Image class is by reading (part of) the
JPEG file yourself, as in the following code:
public static Size GetJpegImageSize(string filename) {
FileStream stream=null;
BinaryReader rdr=null;
try {
stream=File.OpenRead(filename);
rdr=new BinaryReader(stream);
for(; ; ) {
byte code=rdr.ReadByte();
if(code!=0xFF) throw new ApplicationException(
"Unexpected value in file "+filename);
code=rdr.ReadByte();
switch(code) {
case 0xFF:
stream.Position--;
break;
case 0xD0: case 0xD1: case 0xD2: case 0xD3: case 0xD4:
case 0xD5: case 0xD6: case 0xD7: case 0xD8: case 0xD9:
break;
case 0xC0: case 0xC1: case 0xC2: case 0xC3:
case 0xC4: case 0xC5: case 0xC6: case 0xC7:
case 0xC8: case 0xC9: case 0xCA: case 0xCB:
case 0xCC: case 0xCD: case 0xCE: case 0xCF:
ReadBEUshort(rdr);
rdr.ReadByte();
ushort h=ReadBEUshort(rdr);
ushort w=ReadBEUshort(rdr);
return new Size(w, h);
default:
int len=ReadBEUshort(rdr);
stream.Position+=len-2;
break;
}
}
} finally {
if(rdr!=null) rdr.Close();
if(stream!=null) stream.Close();
}
}
private static ushort ReadBEUshort(BinaryReader rdr) {
ushort hi=rdr.ReadByte();
hi<<=8;
ushort lo=rdr.ReadByte();
return (ushort)(hi|lo);
}
A JPEG file contains a lot of packets (with Hufman tables and everything).
The above code does not know much about JPEG, it simply tries to jump from one packet
to the next until it finds one with size info.
|
|
|
|
|
Thanks a TON for that...did you just pull that off the top of your head? Or did you have reference material for that? What information did you refer to?
Welcome my son...Welcome..to the Machine
|
|
|
|
|
Hi,
I once wrote a JPEG file viewer based on the JPEG standard[^].
And today I threw out everything that was not needed when only Size matters...
|
|
|
|
|
...how long did it take you to parse through all of the W3C info to turn it into something useful?
Welcome my son...Welcome..to the Machine
|
|
|
|
|
Actually not very long, I did not read most of the spec, I just looked for the overall
structure (packets with 2B code and 2B length field) and a couple of specifics that did
interest me at the time. And with a simple viewer, I just looked inside a lot of JPEG files
to see what kind of information typically gets included.
BTW a lot of cameras add exposure information (make and model, datetime, image corrections,
etc) to the JPEG files they create, and the Image class allows you to retrieve these
using the getPropertyItem() method.
|
|
|
|
|
...I was thinking that I was going to have to find a way to pull the FileHeader off, store it in the .Net equivalent of a BITMAPFILEHEADER. Then, pull the InfoHeader off of the file and store it in the .NET equivalent of a BITMAPINFOHEADER...& pull the width & height from it
...or by using WMI. That was more along my line of thinking.
Welcome my son...Welcome..to the Machine
|
|
|
|
|
Hi,
The structs you mentioned exist in a .bmp file, not in a JPEG file.
And before you ask, no I dont have a BMP Viewer yet.
As for WMI, I dont think WMI would help looking at JPEGs; it is involved in system resources.
|
|
|
|
|
I know that WMI is for system resources, but I saw an example while I was doing online research where somebody went to the WMI classes for the owner of a specific file (I think he went to one of the Operating System's Win32_Security classes) ...I was just thinking that the information might be included with it *somewhere*
Welcome my son...Welcome..to the Machine
|
|
|
|
|
right...I knew that the BITMAPINFOHEADER was for a bmp & not a jpg ...but I was hoping that something could be done to mimic its usage. (My bmp viewer is in C++...never ported it to .NET) ...bmp's are actually extremely simple, barely a step up from a PPM.
I'm sure you could find it yourself, but the header just looks like this:
height field
bits per pixel field
compression field
colors field
important colors field
...then you just have to remember that bitmaps are encoded as BGR values instead of RGB, so you have to map them accordingly
Welcome my son...Welcome..to the Machine
|
|
|
|
|
ok...one thing I absolutely hate is how .NET throws this for the code you provided:
Error 6 Control cannot fall through from one case label ('case 207:') to another D:\XNA\Files\Projects\Terrain\TerrainWIP\Terrain\Terrain\JPEG.cs 61 58 Terrain
Was your code C#.NET code? How were you able to force it to fall through the cases?
Welcome my son...Welcome..to the Machine
|
|
|
|
|
Hi,
I did not actually run the code I posted, but it seems OK to me.
cases should be empty (that is how you can list cases to share all their code)
or end on a change-of-flow (break, return, throw...)
Did you somehow change the code and violate the above ?
I guess you did, since 207 is 0xCF and that one ended on return...
|
|
|
|
|
no...identical code. Cut & pasted it. .NET's saying that it won't let a case fall through to execute code from another case. ...OxCF was the case that actually had code to execute. ..the others fell through to 0xCF.
Welcome my son...Welcome..to the Machine
|
|
|
|
|
lol...I saw what it was. You forgot your break in the 0xCF code, so it was saying it couldn't fall from 0xCF to the default code.
Welcome my son...Welcome..to the Machine
|
|
|
|
|
...even if you have a return, it still wants you to have the break after it
Welcome my son...Welcome..to the Machine
|
|
|
|