Ignore:
Timestamp:
Dec 22, 2016, 8:49:19 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Updated BGRABitmap package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/bgrabitmap/bgrastreamlayers.pas

    r472 r494  
    1717implementation
    1818
    19 uses BGRABitmapTypes, BGRACompressableBitmap, zstream, BGRAReadLzp, BGRAWriteLzp;
     19uses BGRABitmapTypes, BGRACompressableBitmap, zstream, BGRAReadLzp, BGRAWriteLzp,
     20     BGRAUTF8;
    2021
    2122procedure SaveLayeredBitmapToStream(AStream: TStream; ALayers: TBGRACustomLayeredBitmap);
     
    3738  StreamMaxLayerCount = 4096;
    3839  StreamMaxHeaderSize = 256;
    39 
    40 {$i winstream.inc}
    4140
    4241function CheckStreamForLayers(AStream: TStream): boolean;
     
    9190
    9291    //header size
    93     HeaderSize:= WinReadLongint(AStream);
     92    HeaderSize:= LEReadLongint(AStream);
    9493    if (HeaderSize < 12) or (HeaderSize > StreamMaxHeaderSize) then
    9594      raise exception.Create('Invalid header size');
    9695    LayerStackStartPosition := AStream.Position + HeaderSize;
    9796
    98     NbLayers:= WinReadLongint(AStream);
     97    NbLayers:= LEReadLongint(AStream);
    9998    if (NbLayers < 0) or (NbLayers > StreamMaxLayerCount) then
    10099      raise exception.Create('Invalid layer count');
    101100
    102     ASelectedLayerIndex:= WinReadLongint(AStream);
     101    ASelectedLayerIndex:= LEReadLongint(AStream);
    103102    if (ASelectedLayerIndex < -1) or (ASelectedLayerIndex >= NbLayers) then
    104103      raise exception.Create('Selected layer out of bounds');
    105104
    106     StackOption := WinReadLongint(AStream);
     105    StackOption := LEReadLongint(AStream);
    107106    result.LinearBlend := (StackOption and 1) = 1;
    108107    if (StackOption and 2) = 2 then Compression := lzpRLE else Compression:= lzpZStream;
     
    112111    for i := 0 to NbLayers-1 do
    113112    begin
    114       LayerHeaderSize:= WinReadLongint(AStream);
     113      LayerHeaderSize:= LEReadLongint(AStream);
    115114      LayerHeaderPosition := AStream.Position;
    116115      LayerBitmapPosition := LayerHeaderPosition + LayerHeaderSize;
     
    126125      if AStream.Position <= LayerBitmapPosition-4 then
    127126      begin
    128         LayerOption := WinReadLongint(AStream);
     127        LayerOption := LEReadLongint(AStream);
    129128        LayerVisible := (LayerOption and 1) = 1;
    130129      end;
    131130      if AStream.Position <= LayerBitmapPosition-4 then
    132         LayerBlendOp := TBlendOperation(WinReadLongint(AStream));
     131        LayerBlendOp := TBlendOperation(LEReadLongint(AStream));
    133132
    134133      if AStream.Position <= LayerBitmapPosition-8 then
    135134      begin
    136         LayerOffset := Point(WinReadLongint(AStream),WinReadLongint(AStream));
     135        LayerOffset := Point(LEReadLongint(AStream),LEReadLongint(AStream));
    137136        if AStream.Position <= LayerBitmapPosition-4 then
    138137        begin
    139           LayerId := WinReadLongint(AStream);
     138          LayerId := LEReadLongint(AStream);
    140139          LayerIdFound := true;
    141140        end;
    142141        if AStream.Position <= LayerBitmapPosition-4 then
    143           LayerOpacity := WinReadLongint(AStream) shr 8;
     142          LayerOpacity := LEReadLongint(AStream) shr 8;
    144143      end;
    145144      if AStream.Position <= LayerBitmapPosition-4 then
    146145      begin
    147         LayerBitmapSize := WinReadLongint(AStream);
     146        LayerBitmapSize := LEReadLongint(AStream);
    148147        LayerEndPosition:= LayerBitmapPosition+LayerBitmapSize;
    149148      end;
     
    186185    raise exception.Create('Selected layer out of bounds');
    187186  AStream.Write(StreamHeader[1], length(StreamHeader));
    188   WinWriteLongint(AStream, 12); //header size
    189   WinWriteLongint(AStream, ALayers.NbLayers);
    190   WinWriteLongint(AStream, ASelectedLayerIndex);
     187  LEWriteLongint(AStream, 12); //header size
     188  LEWriteLongint(AStream, ALayers.NbLayers);
     189  LEWriteLongint(AStream, ASelectedLayerIndex);
    191190  StackOption := 0;
    192191  if ALayers.LinearBlend then StackOption := StackOption or 1;
    193192  if ACompression = lzpRLE then StackOption:= StackOption or 2;
    194   WinWriteLongint(AStream, StackOption);
     193  LEWriteLongint(AStream, StackOption);
    195194  //end of header
    196195
     
    198197  begin
    199198    LayerHeaderSizePosition:= AStream.Position;
    200     WinWriteLongint(AStream, 0); //header size not computed yet
     199    LEWriteLongint(AStream, 0); //header size not computed yet
    201200    LayerHeaderPosition := AStream.Position;
    202201
    203202    LayerOption := 0;
    204203    if ALayers.LayerVisible[i] then LayerOption:= LayerOption or 1;
    205     WinWriteLongint(AStream, LayerOption);
    206     WinWriteLongint(AStream, Longint(ALayers.BlendOperation[i]));
    207     WinWriteLongint(AStream, ALayers.LayerOffset[i].x);
    208     WinWriteLongint(AStream, ALayers.LayerOffset[i].y);
    209     WinWriteLongint(AStream, ALayers.LayerUniqueId[i]);
    210     WinWriteLongint(AStream, integer(ALayers.LayerOpacity[i])*$101);
     204    LEWriteLongint(AStream, LayerOption);
     205    LEWriteLongint(AStream, Longint(ALayers.BlendOperation[i]));
     206    LEWriteLongint(AStream, ALayers.LayerOffset[i].x);
     207    LEWriteLongint(AStream, ALayers.LayerOffset[i].y);
     208    LEWriteLongint(AStream, ALayers.LayerUniqueId[i]);
     209    LEWriteLongint(AStream, integer(ALayers.LayerOpacity[i])*$101);
    211210    LayerBitmapSizePosition:=AStream.Position;
    212     WinWriteLongint(AStream, 0);
     211    LEWriteLongint(AStream, 0);
    213212    LayerBitmapPosition:=AStream.Position;
    214213    LayerHeaderSize := LayerBitmapPosition - LayerHeaderPosition;
    215214    AStream.Position:= LayerHeaderSizePosition;
    216     WinWriteLongint(AStream, LayerHeaderSize);
     215    LEWriteLongint(AStream, LayerHeaderSize);
    217216    //end of layer header
    218217
     
    231230      raise exception.Create('Image too big');
    232231    AStream.Position:= LayerBitmapSizePosition;
    233     WinWriteLongint(AStream, BitmapSize);
     232    LEWriteLongint(AStream, BitmapSize);
    234233    AStream.Position:= LayerBitmapPosition+BitmapSize;
    235234  end;
Note: See TracChangeset for help on using the changeset viewer.