有段操作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;