网上也有类似的帖子,但我就是没法显示出来,新手上路,水平有限。
纯数据的8位图像数据,因为图像很大,所以只要显示出来,而且要局部显示(只要能显示出来我想局部显示我是可以自己解决的),不要转化成bmp等格式。我想是应该读一段数据到image里,指定调色板和宽度高度,但就是没法放进去,请有经验的大虾们给一段代码,分不够可以再加,谢谢!
还有——scanline可以成行读出来,有什么方法可以成行写进去的吗?

解决方案 »

  1.   

    procedure RawToBitmap(Stream: TStream;
    const Width, Height, ColorDepth: Integer; Bmp: TBitmap);
    var
    RemLen, DataLen, i: Integer;
    begin
    case ColorDepth of
    1:
    begin
    Bmp.PixelFormat := pf1Bit;
    DataLen := (Width + 7) shr 3;
    end;
    4:
    begin
    Bmp.PixelFormat := pf4Bit;
    DataLen := (Width + 1) shr 1;
    end;
    8:
    begin
    Bmp.PixelFormat := pf8Bit;
    DataLen := Width;
    end;
    15:
    begin
    Bmp.PixelFormat := pf15Bit;
    DataLen := Width shl 1;
    end;
    16:
    begin
    Bmp.PixelFormat := pf16Bit;
    DataLen := Width shl 1;
    end;
    24:
    begin
    Bmp.PixelFormat := pf24Bit;
    DataLen := Width shl 1 + Width;
    end;
    32:
    begin
    Bmp.PixelFormat := pf32Bit;
    DataLen := Width shl 2;
    end;
    end;
    Bmp.Width := Width;
    Bmp.Height := Height;
    RemLen := (DataLen + 3) shr 2 shl 2 - DataLen;Stream.Position := 0;
    for i := 0 to Height - 1 do begin
    Stream.Read(Bmp.ScanLine[Height - 1 - i]^, DataLen);
    if RemLen <> 0 then
    Stream.Seek(RemLen, soFromCurrent);
    end;
    end;
      

  2.   

    我想问的就是如何把已经读出来的数据以图像的方式显示出来。
    http://delphi.137bbs.com/simple/index.php?t77010.html 
    这个帖子可能有帮助,可是其中最后的一段代码  Stream.Read(Bmp.ScanLine[Height - 1 - i]^, DataLen);
    是什么意思啊,编译也过不去。
      

  3.   

    extcsdn(Studing VB now)贴的就是我想问的那个帖子,问题同上。
     Stream.Read(Bmp.ScanLine[Height - 1 - i]^, DataLen);
      

  4.   

    我这样写编译通过,但是执行报错,请大家看一下有什么问题
    procedure TForm1.Button2Click(Sender: TObject);
    var
    i: Integer;
    Stream: TStream;
    Width, Height:Integer;
    ColorDepth: Integer;
    Bmp: TBitmap;
    begin
    Width:=5492;
    Height:=4606;
    ColorDepth:=8;
    Stream:=TFileStream.Create('c://sh.tif', fmCreate or fmShareExclusive);
    Bmp.PixelFormat := pf8Bit;
    Bmp.Width:=Width;
    Stream.Position := 14666;
      for i := 0 to (Height - 1) do begin
      Stream.Read(Bmp.ScanLine[Height - 1 - i]^, Bmp.Width);
      end;
      image1.Picture.Bitmap.Assign(Bmp);
    end;