游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1367|回复: 2

关于卷屏的问题,,不知道错哪啊

[复制链接]

13

主题

25

帖子

25

积分

注册会员

Rank: 2

积分
25
发表于 2007-3-2 18:10:00 | 显示全部楼层 |阅读模式
int Scroll_Bitmap(BITMAP_IMAGE_PTR image, int dx, int dy)
{
// this function scrolls a bitmap

BITMAP_IMAGE temp_image; // temp image buffer

// are the parms valid
if (!image || (dx==0 && dy==0))
   return(0);


// scroll on x-axis first
if (dx!=0)
{
// step 1: normalize scrolling amount
dx %= image->width;

// step 2: which way?
if (dx > 0)
   {
   // scroll right
   // create bitmap to hold region that is scrolled around
   Create_Bitmap(&temp_image, 0, 0, dx, image->height, image->bpp);

   // 拷贝被卷掉的那部分到新建的temp_image中(后一个的Copy_Bitmap就是把temp_image中的部分拷到需要的地方)copy region we are going to scroll and wrap around
   Copy_Bitmap(&temp_image,0,0,
                image, image->width-dx,0,
                dx, image->height);

   // set some pointers up
   UCHAR *source_ptr = image->buffer;  // start of each line
   int shift         = (image->bpp >> 3)*dx;

   // now scroll image to right "scroll" pixels
   for (int y=0; y < image->height; y++)
       {
       // scroll the line over
       memmove(source_ptr+shift, source_ptr, (image->width-dx)*(image->bpp >> 3));
   
       // advance to the next line
       source_ptr+=((image->bpp >> 3)*image->width);
       } // end for
   
   // and now copy it back
   Copy_Bitmap(image, 0,0, &temp_image,0,0,
               dx, image->height);           

   } // end if
else  if (dx<0){雷同,不写了}
///////////////////////X轴部分是书上的,可以横向卷动,以下是我加入的Y轴的部分,上下移动时却变成花屏,满屏都是竖线//////////////////////////
else
if (dy!=0)
{
dy%= image->height;

/*if(dy >0)
   {
   // scroll right
   // create bitmap to hold region that is scrolled around
   Create_Bitmap(&temp_image, 0, 0, image->width, dy , image->bpp);

   // copy region we are going to scroll and wrap around
   Copy_Bitmap(&temp_image,0,0,
                image, 0, image->height-dy,
                image->width, dy );

   // set some pointers up
   UCHAR *source_ptr = image->buffer;  // start of each line
   int shift         = (image->bpp >> 3)* image->width*dy;

   // now scroll image to right "scroll" pixels
   for (int y=0; y < image->height; y++)
       {
       // scroll the line over
       memmove(source_ptr+((image->bpp >> 3)*image->width)*dy, source_ptr, image->width*(image->bpp >> 3));
   
       // advance to the next line
       source_ptr+=((image->bpp >> 3)*image->width);
       } // end for
   
   // and now copy it back
   Copy_Bitmap(image, 0,0, &temp_image,0,0,
               image->width, dy );           

   } // end if
} // end scroll on x-axis

// return success
return(1);

} // end Scroll_Bitmap
*/
///////////////////////////////////////////////////////////
究竟错哪了,我认为步长要改为mempitch而不时用image->width,但编译时说此变量未申明,要怎么办


   

sf_20073218956.doc

36.5 KB, 下载次数:

13

主题

25

帖子

25

积分

注册会员

Rank: 2

积分
25
 楼主| 发表于 2007-3-5 12:35:00 | 显示全部楼层

Re:关于卷屏的问题,,不知道错哪啊

指点指点

362

主题

3023

帖子

3553

积分

论坛元老

Rank: 8Rank: 8

积分
3553
发表于 2007-3-5 16:31:00 | 显示全部楼层

Re:关于卷屏的问题,,不知道错哪啊

你这个什么乱七八糟的,不如描述一下,我来重写
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-4-13 09:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表