我在做一个抽奖程序, 在按下空格键前要不断地切换图片,
我用TImage的picture的loadfromfile来切换图片,但是发现图片显示得太慢了, 就是切换图片的时候会显示出窗口背景来了有没有办法可以快速地切换到图片?

解决方案 »

  1.   

    ImgPhoto.Picture.Bitmap.FreeImage;
      //ImgStream := TMemoryStream.Create;
      ImgJPG := TJPEGImage.Create;
      try
        try
          //LJP 不预读照片
          with DM.qrExec do
          begin
            Close;
            SQL.Clear;
            SQL.Add('select Photo from PM_Staffer_T where PK_Staffer_ID=' + QuotedStr(DataSet.FieldByName(L_FIELD_YGBH).AsString)+' AND PK_Mine_ID='+QuotedStr(SystemParam.__MineID));
            Open;
          end;
          if DM.qrExec.RecordCount > 0 then
          begin
            //解决报“JPEG error #53”错误。
            ImgStream := TMemoryStream(DataSet.CreateBlobStream(DM.qrExec.FieldByName('Photo'), bmRead));
            try
              if ImgStream.Size > 0 then
              begin
                ImgJPG.LoadFromStream(ImgStream);
                ImgPhoto.Picture.Bitmap.Assign(ImgJPG);
              end
              else
                ImgPhoto.Picture.Assign(nil);
            finally
              ImgStream.Free;
            end;
          end;
          DM.qrExec.Close;
        except
        end;
      finally
        ImgJPG.Free;
      end;你研究一下吧,我这个支持鼠标滚轮更换图片,那个速度也还比较快的
      

  2.   

    手动创建几个image对象,启动的时候把图片就加载到对象里然后再互相调用,貌似快点
      

  3.   

    使用TList列表来处理,把图片先加入到TList中保存起来,动态切换的的时候,动态调用就可以了。
      

  4.   

    即使把图片都装进内存, 显示起来还是有闪烁最后在FormCreate里加一句DoubleBuffered := true;搞定了