【问题标题】:Size of java.awt.Color objectjava.awt.Color 对象的大小
【发布时间】:2013-04-10 17:13:12
【问题描述】:

我有一个程序,其中我在套接字上使用 ObjectStream。我发送的类的代码如下所示。

class Snake{
Point[] p = new Point[50];
Direction move;
public int length;
int score;
String player;
Color snakecolor;
boolean gameover;
//Other Functions go here//    
}

这个类通过套接字重复发送。然而,它显示出一些滞后。如果不是发送 Color 对象而是发送 RGB 代码(整数值),它会产生很大的不同吗?我怎么可能让我的程序没有延迟?

【问题讨论】:

标签: java jquery sockets lag object-serialization


【解决方案1】:

documentation开始,序列化Color的以下字段:

int value
float[] frgbvalue
float[] fvalue
float falpha
ColorSpace cs

ColorSpacehas the following serialized fields:

int type
int numComponents

frgbValuefvalue 包含 3 个元素,因此总大小为 40 字节。仅发送 RGB 将是 12 个字节。我认为这不会解决你的滞后问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-25
    • 1970-01-01
    • 2010-10-12
    • 2011-11-01
    • 2010-12-05
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    相关资源
    最近更新 更多