| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 659 人关注过本帖
标题:有段操作bmp文件的,谁能帮我看下啊,我想改写成其他语言
只看楼主 加入收藏
face08
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-7-1
收藏
 问题点数:0 回复次数:0 
有段操作bmp文件的,谁能帮我看下啊,我想改写成其他语言
程序代码:
procedure TMainForm.BuildSpriteBitmap(var Bitmap: TBitmap;
  BackgroundColor: TColor);
var
  I, DrawLeft, DrawTop: Integer;
  IncHeight, MaxWidth, MaxHotpointX: Integer;
  BitmapInfo: TBitmapInfo256;
begin
{$IFDEF DEBUG}
  Assert(Assigned(FArchive));
{$ENDIF}
  DrawTop := 0;
  IncHeight := 0;
  MaxWidth := 0;
  MaxHotpointX := 0;

  Bitmap.FreeImage;
  Bitmap.Assign(nil);

  try
    //找出最大宽高
    for I := 0 to FArchive.SlpFileHeader.FrameCount - 1 do
    begin
      Inc(IncHeight, FArchive.SlpFrameItems[I].Size.cy);
      MaxWidth := Max(MaxWidth, FArchive.SlpFrameItems[I].Size.cx);
      MaxHotpointX := Max(MaxHotpointX, FArchive.SlpFrameItems[I].HotPoint.X);
    end;

    with Bitmap do
    begin
      Height := IncHeight;
      Width := MaxWidth;
      Canvas.Brush.Color := $FF0000;
      Canvas.FillRect(Rect(0, 0, Width, Height));
    end;

    Move(FMaxLogPalette.palPalEntry, BitmapInfo.bmiColors,
      SizeOf(BitmapInfo.bmiColors));

    //FArchive.SlpFileHeader.FrameCount - 1
    for I := 0 to 1 do
    begin
      with BitmapInfo.bmiHeader do
      begin
        biSize := SizeOf(TBitmapInfoHeader);
        biWidth := FArchive.SlpFrameItems[I].Size.cx;
        biHeight := -FArchive.SlpFrameItems[I].Size.cy;  // 垂直翻转位图
        biPlanes := 1;
        biBitCount := 8;
        biCompression := BI_RGB;
        biSizeImage := 0;
        biXPelsPerMeter := 0;
        biYPelsPerMeter := 0;
        biClrUsed := 0;
        biClrImportant := 0;
      end;
      //对齐
      if not mniAlign.Checked or
        (MaxHotpointX - FArchive.SlpFrameItems[I].HotPoint.X > MaxWidth) then
        DrawLeft := 0
      else
        DrawLeft := MaxHotpointX - FArchive.SlpFrameItems[I].HotPoint.X;
//      SetDIBitsToDevice(Handle,DrawLeft,DrawTop,cx)
      with Bitmap.Canvas, FArchive.SlpFrameItems[I].Size do
      begin
        SetDIBitsToDevice(Handle, DrawLeft, DrawTop, cx, cy, 0, 0, 0, cy,
          @FArchive.SlpFramesBits[I][0], PBitmapInfo(@BitmapInfo)^,
          DIB_RGB_COLORS);
//        OutputDebugString(PAnsiChar(IntToStr(FArchive.SlpFramesBits[I][75])));
        Inc(DrawTop, FArchive.SlpFrameItems[I].Size.cy);
      end

    end;
  finally
  end;
end;
搜索更多相关主题的帖子: 其他 
2012-07-01 21:06
快速回复:有段操作bmp文件的,谁能帮我看下啊,我想改写成其他语言
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017130 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved