我在玄武岩平台上使用Pebble SDK 3.0编写Pebble Time Watch应用程序,需要文本显示为颠倒。翻转卵石屏幕问题
的逻辑是: -
- 写入屏幕
- 捕获屏幕缓冲器
- 翻转屏幕缓冲器(使用常规flipHV,见下文)
- 推出缓冲器。
经过大量的实验后,我已经在时尚之后工作,但(黑色)文本有什么似乎是随机的垂直白线通过它(见下图),我怀疑是要做的事情随着位移动。
我使用的子程序: -
void flipHV(GBitmap *bitMap) {
GRect fbb = gbitmap_get_bounds(bitMap);
int Width = 72; // fbb.size.w;
int Height = 84; // fbb.size.h;
uint32_t *pBase = (uint32_t *)gbitmap_get_data(bitMap);
uint32_t *pTopRemainingPixel = pBase;
uint32_t *pBottomRemainingPixel = pBase + (Height * Width);
while (pTopRemainingPixel < pBottomRemainingPixel) {
uint32_t TopPixel = *pTopRemainingPixel;
uint32_t BottomPixel = *pBottomRemainingPixel;
TopPixel = (TopPixel << 16) | (TopPixel >> 16);
*pBottomRemainingPixel = TopPixel;
BottomPixel = (BottomPixel << 16) | (BottomPixel >> 16);
*pTopRemainingPixel = BottomPixel;
pTopRemainingPixel++;
pBottomRemainingPixel--;
}
}
,其目的是,虽然屏幕缓冲区以第一像素,并与最后一个,第二个和交换工作交换它与第二个最后一个等等等
因为每个32位“字节”保存2个像素,我也需要通过16位旋转它。
我怀疑这是问题所在。
有人可以看看我的代码,看看他们是否可以看到发生了什么问题,并把我的权利。我应该说我既是C和Pebble SDK的新手,也请给孩子解释一切!
谢谢,我会试试看。 –
我已经通过将所有内容声明为uint8_t来解决此问题。但是,主要的问题是图像宽度和图像宽度之间的字节差异(对于除GBitmapFormat8Bit以外的任何其他内容)并不相同,并且需要额外的处理来考虑未使用的字节。答案可以在http://forums.getpebble.com/discussion/27862/puzzling-gbitmap-get-data-behaviour#latest找到。 –