psplash进度条旋转成功

转载地址:https://blog.csdn.net/zhanzheng520/article/details/13002459

pspfalsh是一个嵌入式中显示开机进度的开源软件,http://wiki.openmoko.org/wiki/Splash_screen可以看到相关的一些内容,看了一下,大概是什么进行开机界面设置的一个程序,好像不止一个,分什么Splash screen、U-boot Splash 、psplash 、X splash等,看样子是用在不同的阶段吧,这里只需搞定psplash就可以了。
  psplash开机画面的大概修改过程如下:
  先准备一个png图片文件,
      make-image-header.sh my_image.png HAND
      进行处理,
      mv my_image-img.h psplash-hand-img.h
      修改名字,
      然后configure,然后make,有效,开机画面被成功修改为所准备的png图片。

因为屏的方向与通常的不一致,且旋转参数修改无效,开机画面可以重新绘制,但进度条的方向非得自己改代码了。

首先通常运行时总出现一条横贯左右的白条,经查,该函数作怪,

/* Clear */

  /*psplash_fb_draw_rect (fb, 
   0, 
   fb->height - (fb->height/6) - h, 
   fb->width,
   h,
   0xec, 0xec, 0xe1);*/

删后该问题解决。

 关于进度条,先删了一个进度条的外框函数,感觉没什么用,删后效果还好,该函数为:

/* Draw progress bar border */
  /*psplash_fb_draw_image (fb, 
    (fb->width  - BAR_IMG_WIDTH)/2, 
    fb->height - (fb->height/10), 
    BAR_IMG_WIDTH,
    BAR_IMG_HEIGHT,
    BAR_IMG_BYTES_PER_PIXEL,
    BAR_IMG_RLE_PIXEL_DATA);*/

查看psplash.c里边有关于进度条的函数,

psplash_draw_progress (PSplashFB *fb, int value)
{
  int x, y, width, height, barwidth;

  /* 4 pix border */
  x      = ((fb->width  - BAR_IMG_WIDTH)/2) + 4 ;
  y      = fb->height - (fb->height/6) + 4;
  width  = BAR_IMG_WIDTH - 8; 
  height = BAR_IMG_HEIGHT - 8;

  if (value > 0)
    {
      barwidth = (CLAMP(value,0,100) * width) / 100;
      psplash_fb_draw_rect (fb, x + barwidth, y, 
       width - barwidth, height,
   0xec, 0xec, 0xe1);
      psplash_fb_draw_rect (fb, x, y, barwidth,
       height, 0x6d, 0x6d, 0x70);
    }
  else
    {
      barwidth = (CLAMP(-value,0,100) * width) / 100;
      psplash_fb_draw_rect (fb, x, y, 
       width - barwidth, height,
   0xec, 0xec, 0xe1);
      psplash_fb_draw_rect (fb, x + width - barwidth,
       y, barwidth, height,
       0x6d, 0x6d, 0x70);
    }

  DBG("value: %i, width: %i, barwidth :%i/n", value, 
  width, barwidth);
}

看了一下,也就是画方框,之后根据进度画着了色的进度框,改代码如下:

void
psplash_draw_progress (PSplashFB *fb, int value)
{
  int x, y, width, height, barhight;

   x      = 100;
   y      = ((fb->height  - BAR_IMG_WIDTH)/2) + 4;

 width  =BAR_IMG_HEIGHT - 16;//width  = BAR_IMG_WIDTH - 8;
 // height = BAR_IMG_HEIGHT - 8;
  height = BAR_IMG_WIDTH - 8;//height = BAR_IMG_HEIGHT - 16;


  if (value > 0)
    {
      //barwidth = (CLAMP(value,0,100) * width) / 100;
      barhight = (CLAMP(value,0,100) * height ) / 100;
      psplash_fb_draw_rect (fb, x , y+ barhight,//psplash_fb_draw_rect (fb, x + barwidth, y, 
       width , height- barhight,//width - barwidth, height,
   0xec, 0xec, 0xe1);
      psplash_fb_draw_rect (fb, x, y, width,
       barhight, 0x6d, 0x6d, 0x70);
    }
  else
    {
      barhight = (CLAMP(-value,0,100) *  height) / 100;
      psplash_fb_draw_rect (fb, x, y, 
       width, height- barhight,
   0xec, 0xec, 0xe1);
      psplash_fb_draw_rect (fb, x,
       y, width, barhight,
       0x6d, 0x6d, 0x70);
    }

  DBG("value: %i, width: %i, barhight :%i/n", value, 
  width, barhight);
}

改后一试,ok,效果还不错。

猜你喜欢

转载自blog.csdn.net/kunkliu/article/details/81125695
今日推荐