如何处理JPG,BMP图片(转换为0,1的2进制文件)?
我有1年多没摸DELPHI,以前做过数据库,记得要用到TBMP,还有其他的什么,JPG那种可以动的图片是怎么回事?
在此谢谢了!

解决方案 »

  1.   

    用TMemoryStream, TFileMemory 的loadfromfile 打開就是你要的:
    >>如何处理JPG,BMP图片(转换为0,1的2进制文件)?
      

  2.   

    用Memo 的 lines.loadFromFile 直接打開一個 jpg, bmp 應該也是你要的!>>,JPG那种可以动的图片是怎么回事?
    那是另外一種格式 mjpg, 查下就知道
      

  3.   

    你指的处理是什么意思?
    格式转换还是变成矩阵?
    假如格式转换.用TBitMap TJPEGImage都行
    假如只需得到矩阵,aiirii的办法即可
      

  4.   

    利用TBitMap的ScanLine属性是我所知的最好方法。
    可以在CSDN搜索一下ScanLine的用法
      

  5.   

    我打算用IMAGE打开图片,然后用TBitMap的ScanLine属性.
      

  6.   

    如何将得到的数据生成一个"*.BIN"文件?
      

  7.   

    我想你要的是灰度级处理吧:
    procedure Gray(var bmp: TBitmap);
    var
      p: PByteArray;
      w: Integer;
      i, j: Integer;
    begin
      bmp.pixelformat := pf24bit;
      for i := 0 to bmp.height - 1 do
      begin
        p := bmp.scanline[i];
        j := 0;
        while j < (bmp.width-1) * 3 do
        begin
          w :=(p[j] * 28 + p[j+1] * 151 + p[j+2]*77);
          w := w shr 8;
          p[j] := byte(w);
          p[j+1] := byte(w);
          p[j+2] := byte(w);
          inc(j, 3)
        end;
      end;
    end; 然后保存为文件就行了
      

  8.   

    那还看得清吗
      Image1.Picture.LoadFromFile('F:\2.bmp');
      Image1.Picture.Bitmap.PixelFormat := pf1bit;//2位,黑与白
    上面就是你要的
      

  9.   

    procedure TForm1.BitBtn3Click(Sender: TObject);
      var
        fileext : string;
    begin
      if (edit1.Text ) =''  then
         begin
             edit1.SetFocus;
             exit;
         end;
      if (edit2.Text ) =''  then
         begin
             edit2.SetFocus;
              exit;
         end;
      if(OpenPictureDialog1.Execute) then
        begin
          fileext :=  UpperCase(ExtractFileExt(OpenPictureDialog1.FileName));
          if (fileext = '.BMP') or (fileext = '.JPG')   then
              begin
                  Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
                  BitBtn1.Enabled :=true;
              end
           else
              begin
                 if (Application.MessageBox('你的图片文件格式不对,退出转换?','提示',MB_YESNO) = IDYES )  then
                 exit;
              end;   
          Edit3.Text := OpenPictureDialog1.FileName;
        end
      else
        begin
          Edit3.Text :='';
        end;
      if((Image1.Picture.Height > MAXWIDTH) or ( Image1.Picture.Width >MAXLEN )) then
         if(Application.MessageBox('你的图片尺寸超出96*32!,退出转换?','提示',MB_YESNO) = IDYES )  then
                 exit;
    end;procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      i,j,w,row : Integer;
      BitMap : TBitMap;
      P : PByteArray;
      FileArr: array[0..MAXLEN*2-1] of Byte;
       FilePath:string;
       mask:Byte;
    begin
      FilePath := ExtractFilePath(Application.EXEName)  ;
      BitMap := TBitMap.create;
      BitMap.pixelformat  :=pf24bit; //pf24bit pf1bit
      try
          BmpStr:=TFileStream.Create(FilePath+'LOGO.bin',fmCreate);
      except
         BmpStr.Free;
      end;
      
      try
        BitMap.LoadFromFile(OpenPictureDialog1.FileName);
      except
        BitMap.Free;
      end;
      BmpStr.Seek(0,soFromBeginning);
      row := 0;
      for w := 0 to 3 do
      begin
           for i := 0 to MAXLEN-1 do
                   FileArr[i] := 0;        BmpStr.Seek(0,soFromCurrent);
            mask:=$80;
            for i := 0+row to 7+row do
            begin
                p := BitMap.scanline[i];
                j := 0;
                while j < (MAXLEN-1) * 3 do
                begin
                        if(p[j] = p[j+1]) and (p[j+2] = p[j+1]) and (p[j+2] = 255) then
                         begin
                            Label7.Caption := '1';
                            FileArr[i] :=  (FileArr[i] or  mask);
                         end
                        else
                          Label7.Caption := '0';
                        inc(j, 3)
               end;
               mask:=mask shr 1;
            end;
         BmpStr.Write(FileArr,MAXLEN);
         row := row + 8;
     end;
     
     BmpStr.Destroy;
     Application.MessageBox('转换结束!','提示',MB_OK );
    end;我想得到的是张黑白图片的数据,
    结果在看图工具(1:黑,0:白)调用LOGO.BIN文件后看到的结果是条斜线??
    麻烦各位帮我看看数据是否取错了?
      

  10.   

    procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      i,j,w,row,Fsi : Integer;
      BitMap : TBitMap;
      P : PByteArray;
      FileArr: array[0..MAXLEN-1] of Byte;
       FilePath:string;
       mask:Byte;
    begin
      FilePath := ExtractFilePath(Application.EXEName)  ;
      BitMap := TBitMap.create;
      BitMap.pixelformat  :=pf24bit; //pf24bit pf1bit
      try
          BmpStr:=TFileStream.Create(FilePath+'LOGO.bin',fmCreate);
      except
         BmpStr.Free;
      end;
      
      try
        BitMap.LoadFromFile(OpenPictureDialog1.FileName);
      except
        BitMap.Free;
      end;
      BmpStr.Seek(0,soFromBeginning);
      row := 0;  for w := 0 to 3 do
      begin
             for i := 0 to MAXLEN-1 do
                   FileArr[i] := 0;        BmpStr.Seek(0,soFromCurrent);
            mask:=$80;
            for i := 0+row to 7+row do
            begin
                p := BitMap.scanline[i];
                j := 0;
                Fsi := 0;
                while j < (MAXLEN-1) * 3 do
                begin
                        if(p[j] = p[j+1]) and (p[j+2] = p[j+1]) and (p[j+2] = 255) then
                         begin
                            Label7.Caption := '1';
                            FileArr[Fsi] :=  (FileArr[Fsi] or  mask);
                         end
                        else
                          Label7.Caption := '0';
                        inc(j, 3) ;
                        inc(Fsi,1);
               end;
               mask:=mask shr 1;
            end;
         BmpStr.Write(FileArr,MAXLEN);
         row := row + 8;
     end;
     
     BmpStr.Destroy;
     Application.MessageBox('转换结束!','提示',MB_OK );
    end;
    修改了一下,得到的还是不对:(
      

  11.   


    ////////////////////////////////
    我在外,没时间详写了。就要去坐车了
    给点提示定义一个PByte=^Byte
    L:PByte;// 处理8位
    L := Bit.ScanLine[0];// 把黑白调换,电脑显示白色为1黑为0
    // 具体我也不记得,试试吧
    L^ := NOT L^;
    for i := 0 to 7 do
    begin
      // 注意,此处在实际应用还要把第1位与第8位调换,2与7换,我写过一个小程序的,
      // 现在在外上班,不能很好上网。只能给你点提示了。
      if ((L^ SHR i) and 1) = 1 then
      beign
        ShowMessage('1');
      end
      else begin
        ShowMessage('0')
      end;
    end;
      

  12.   

    以下绝对应该是你需要的!!bmp和jpg文件的加密和解密(保存为2进制文件)
    先来bmp的如下!
    unit ScreenCryptBMP;interfaceuses
       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
       ExtCtrls, StdCtrls, ExtDlgs;type
       TFormCrypt = class(TForm)
          ButtonLoad: TButton;
          ImageOriginal: TImage;
          ImageEncrypted: TImage;
          ImageDecrypted: TImage;
          ButtonEncrypt: TButton;
          ButtonDecrypt: TButton;
          ButtonSave: TButton;
          EditSeedEncrypt: TEdit;
          LabelSeedEncrypt: TLabel;
          CheckBoxStretch: TCheckBox;
          SavePictureDialog: TSavePictureDialog;
          OpenPictureDialog: TOpenPictureDialog;
          LabelSeedDecrypt: TLabel;
          EditSeedDecrypt: TEdit;
          procedure FormDestroy(Sender: TObject);
          procedure ButtonLoadClick(Sender: TObject);
          procedure ButtonEncryptClick(Sender: TObject);
          procedure ButtonDecryptClick(Sender: TObject);
          procedure CheckBoxStretchClick(Sender: TObject);
          procedure EditSeedEncryptChange(Sender: TObject);
          procedure EditSeedDecryptChange(Sender: TObject);
          procedure EditNumericKeyPress(Sender: TObject; var Key: Char);
          procedure ButtonSaveClick(Sender: TObject);
       private
          BitmapOriginal: TBitmap;
          BitmapEncrypted: TBitmap;      procedure DecryptImage;
          procedure EncryptImage;
       public
          { Public declarations }
       end;var
       FormCrypt: TFormCrypt;implementation
    {$R *.DFM}uses
       ShellAPI; // ShellExecute
    procedure TFormCrypt.EncryptImage;
    var
       i: INTEGER;
       j: INTEGER;
       RandomValue: BYTE;
       rowIn: pByteArray;
       rowOut: pByteArray;
       ScanlineByteCount: INTEGER;
    begin
       if Assigned(BitmapEncrypted)
          then BitmapEncrypted.Free;   BitmapEncrypted := TBitmap.Create;
       BitmapEncrypted.Width := BitmapOriginal.Width;
       BitmapEncrypted.Height := BitmapOriginal.Height;
       BitmapEncrypted.PixelFormat := BitmapOriginal.PixelFormat;    if BitmapOriginal.PixelFormat in [pf1bit, pf4bit, pf8bit]
          then BitmapEncrypted.Palette := CopyPalette(BitmapOriginal.Palette);    ScanlineByteCount := ABS(Integer(BitmapOriginal.Scanline[1]) -
          Integer(BitmapOriginal.Scanline[0]));   try
          RandSeed := StrToInt(EditSeedEncrypt.Text)
       except
          RandSeed := 79997 // use this prime number if entry is invalid
       end;   for j := 0 to BitmapOriginal.Height - 1 do
          begin
             RowIn := BitmapOriginal.Scanline[j];
             RowOut := BitmapEncrypted.Scanline[j];         for i := 0 to ScanlineByteCount - 1 do
                begin
                   RandomValue := Random(256);
                   RowOut[i] := RowIn[i] xor RandomValue
                end
          end;   ImageEncrypted.Picture.Graphic := BitmapEncrypted;   DecryptImage;   ButtonDecrypt.Enabled := TRUE;
       ButtonSave.Enabled := TRUE
    end {EncryptImage};
    procedure TFormCrypt.DecryptImage;
    var
       BitmapDecrypted: TBitmap;
       i: INTEGER;
       j: INTEGER;
       RandomValue: BYTE;
       rowIn: pByteArray;
       rowOut: pByteArray;
       ScanlineByteCount: INTEGER;
    begin
       BitmapDecrypted := TBitmap.Create;
       BitmapDecrypted.Width := BitmapEncrypted.Width;
       BitmapDecrypted.Height := BitmapEncrypted.Height;
       BitmapDecrypted.PixelFormat := BitmapEncrypted.PixelFormat;   // Copy palette if palettized image
       if BitmapEncrypted.PixelFormat in [pf1bit, pf4bit, pf8bit]
          then BitmapDecrypted.Palette := CopyPalette(BitmapEncrypted.Palette);   // This finds the number of bytes per scanline regardless of PixelFormat
       ScanlineByteCount := ABS(Integer(BitmapEncrypted.Scanline[1]) -
          Integer(BitmapEncrypted.Scanline[0]));   try
          RandSeed := StrToInt(EditSeedDecrypt.Text)
       except
          RandSeed := 79997 // use this prime number if entry is invalid
       end;   for j := 0 to BitmapEncrypted.Height - 1 do
          begin
             RowIn := BitmapEncrypted.Scanline[j];
             RowOut := BitmapDecrypted.Scanline[j];         for i := 0 to ScanlineByteCount - 1 do
                begin
                   RandomValue := Random(256);
                   RowOut[i] := RowIn[i] xor RandomValue
                end
          end;   ImageDecrypted.Picture.Graphic := BitmapDecrypted;
       EditSeedDecrypt.Enabled := TRUE;
    end {DecryptImage};
    procedure TFormCrypt.FormDestroy(Sender: TObject);
    begin
       BitmapOriginal.Free;
       BitmapEncrypted.Free
    end;
    procedure TFormCrypt.ButtonLoadClick(Sender: TObject);
    begin
       if OpenPictureDialog.Execute
          then begin
             if Assigned(BitmapOriginal)
                then BitmapOriginal.Free;         BitmapOriginal := TBitmap.Create;
             BitmapOriginal.LoadFromFile(OpenPictureDialog.Filename);
             ImageOriginal.Picture.Graphic := BitmapOriginal;         ButtonEncrypt.Enabled := TRUE;
             EditSeedEncrypt.Enabled := TRUE;
          end
    end;
    procedure TFormCrypt.ButtonEncryptClick(Sender: TObject);
    begin
       EncryptImage
    end;
    procedure TFormCrypt.ButtonDecryptClick(Sender: TObject);
    begin
       DecryptImage
    end;
    procedure TFormCrypt.CheckBoxStretchClick(Sender: TObject);
    begin
       ImageOriginal.Stretch := CheckBoxStretch.Checked;
       ImageEncrypted.Stretch := CheckBoxStretch.Checked;
       ImageDecrypted.Stretch := CheckBoxStretch.Checked
    end;
    procedure TFormCrypt.EditSeedEncryptChange(Sender: TObject);
    begin
       EncryptImage
    end;
    procedure TFormCrypt.EditSeedDecryptChange(Sender: TObject);
    begin
       DecryptImage
    end;procedure TFormCrypt.EditNumericKeyPress(Sender: TObject;
       var Key: Char);const
       Backspace = #$08;
    begin
       if not (Key in [Backspace, '0'..'9'])
          then Key := #$00
    end;
    procedure TFormCrypt.ButtonSaveClick(Sender: TObject);
    begin
       if SavePictureDialog.Execute
          then BitmapEncrypted.SaveToFile(SavePictureDialog.Filename)
    end;end.
      

  13.   

    再来jpg的!!如下:
    unit ScreenCryptJPEG;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ExtCtrls, StdCtrls, ExtDlgs, JPEG;type
      TFormCrypt = class(TForm)
        ButtonLoadJPG: TButton;
        ImageOriginal: TImage;
        ImageEncrypted: TImage;
        ImageDecrypted: TImage;
        ButtonEncrypt: TButton;
        ButtonDecrypt: TButton;
        ButtonSaveBIN: TButton;
        EditSeedEncrypt: TEdit;
        LabelSeedEncrypt: TLabel;
        CheckBoxStretch: TCheckBox;
        LabelSeedDecrypt: TLabel;
        EditSeedDecrypt: TEdit;
        OpenPictureDialog: TOpenPictureDialog;
        SaveDialog: TSaveDialog;
        ButtonLoadBIN: TButton;
        OpenDialog: TOpenDialog;
        procedure FormDestroy(Sender: TObject);
        procedure ButtonLoadJPGClick(Sender: TObject);
        procedure ButtonEncryptClick(Sender: TObject);
        procedure ButtonDecryptClick(Sender: TObject);
        procedure CheckBoxStretchClick(Sender: TObject);
        procedure EditSeedEncryptChange(Sender: TObject);
        procedure EditSeedDecryptChange(Sender: TObject);
        procedure LabelLab2Click(Sender: TObject);
        procedure EditNumericKeyPress(Sender: TObject; var Key: Char);
        procedure ButtonSaveBINClick(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure ButtonLoadBINClick(Sender: TObject);
      private    
        JPEGOriginalBinary :  TMemoryStream; // Cannot be directly displayed in TImage
        JPEGEncryptedBinary:  TMemoryStream; // Cannot be directly displayed in TImage    PROCEDURE DecryptImage;
        PROCEDURE EncryptImage;
      public
        { Public declarations }
      end;var
      FormCrypt: TFormCrypt;implementation
    {$R *.DFM}  USES
        ShellAPI;  // ShellExecute  // Create pf24bit "noise" image using random numbers
      FUNCTION CreateNoiseImage(CONST Width, Height:  INTEGER):  TBitmap;
        VAR
          i  :  INTEGER;
          j  :  INTEGER;
          row:  pByteArray;
      BEGIN
        RESULT             := TBitmap.Create;
        RESULT.Width       := Width;
        RESULT.Height      := Height;
        RESULT.PixelFormat := pf24bit;    FOR j := 0 TO Height-1 DO
        BEGIN
          row := RESULT.Scanline[j];
          FOR i := 0 TO 3*Width-1 DO   // 3 bytes per pixel
          BEGIN
            row[i] := Random(256)
          END
        END
      END {CreateNoiseImage};
      // Encrypt bytes in JPEGOriginalBinary TMemoryStream to give JPEGEncryptedBinary
      PROCEDURE TFormCrypt.EncryptImage;
        VAR
          BitmapDisplay:  TBitmap;
          i            :  INTEGER;
          pIn          :  pByte;
          pOut         :  pByte;
          RandomValue  :  BYTE;
      BEGIN
        TRY
          RandSeed := StrToInt(EditSeedEncrypt.Text)
        EXCEPT
          RandSeed := 67547  // use this prime number if entry is invalid
        END;    IF   Assigned(JPEGEncryptedBinary)
        THEN JPEGEncryptedBinary.Free;    JPEGEncryptedBinary := TMemoryStream.Create;    // Encrypted version same size as the original version
        JPEGEncryptedBinary.Size := JPEGOriginalBinary.Size;    pIn  := JPEGOriginalBinary.Memory;
        pOut := JPEGEncryptedBinary.Memory;
        FOR i := 1 TO JPEGOriginalBinary.Size DO
        BEGIN
          RandomValue := Random(256);       //  0..255
          pOut^ := pIn^ XOR RandomValue;
          INC(pIn);
          INC(pOut)
        END;    // JPEGEncryptedBinary cannot be displayed as an image.  So, let's just
        // create a "noise" bitmap to display instead.  The "seed" for this noise
        // image will be the RandSeed left over from the JPEG encryption, so the
        // same noise image will be created for a given JPEG.    BitmapDisplay := CreateNoiseImage(ImageEncrypted.Width,
                                          ImageEncrypted.Height);
        TRY
          ImageEncrypted.Picture.Graphic := BitmapDisplay;
        FINALLY
          BitmapDisplay.Free
        END;    DecryptImage;    ButtonDecrypt.Enabled := TRUE;
        ButtonSaveBIN.Enabled := TRUE  END {EncryptImage};
      PROCEDURE TFormCrypt.DecryptImage;
        VAR
          BitmapDisplay      :  TBitmap;
          i                  :  INTEGER;
          JPEGDecrypted      :  TJPEGImage;
          JPEGDecryptedBinary:  TMemoryStream;
          pIn                :  pByte;
          pOut               :  pByte;
          RandomValue        :  BYTE;
      BEGIN
        TRY
          RandSeed := StrToInt(EditSeedDecrypt.Text)
        EXCEPT
          RandSeed := 67547  // use this prime number if entry is invalid
        END;    JPEGDecryptedBinary := TMemoryStream.Create;
        TRY      // Decrypted version same size as the encrypted version
          JPEGDecryptedBinary.Size := JPEGEncryptedBinary.Size;      pIn  := JPEGEncryptedBinary.Memory;
          pOut := JPEGDecryptedBinary.Memory;
          FOR i := 1 TO JPEGEncryptedBinary.Size DO
          BEGIN
            RandomValue := Random(256);       //  0..255
            pOut^ := pIn^ XOR RandomValue;
            INC(pIn);
            INC(pOut)
          END;      // At this point the decrypted JPEG binary stream is in the
          // JPEGDecryptedBinary stream.  Load this memory stream into the
          // JPEGDecrypted TJPEGImage.
          JPEGDecrypted := TJPEGImage.Create;
          TRY
            TRY
              JPEGDecrypted.LoadFromStream(JPEGDecryptedBinary);
              ImageDecrypted.Picture.Graphic := JPEGDecrypted;
            EXCEPT
              // If any error occurs in the conversion, just show a noise image
              BitmapDisplay := CreateNoiseImage(ImageEncrypted.Width, ImageEncrypted.Height);
              TRY
                ImageDecrypted.Picture.Graphic := BitmapDisplay;
              FINALLY
                BitmapDisplay.Free
              END;
            END
          FINALLY
            JPEGDecrypted.Free
          END
        FINALLY
          JPEGDecryptedBinary.Free
        END;    EditSeedDecrypt.Enabled := TRUE;
      END {DecryptImage};
    procedure TFormCrypt.FormDestroy(Sender: TObject);
    begin
      JPEGOriginalBinary.Free;
      JPEGEncryptedBinary.Free
    end;
    procedure TFormCrypt.ButtonLoadJPGClick(Sender: TObject);
      VAR
        JPEGOriginal:  TJPEGImage;
    begin
      IF   OpenPictureDialog.Execute
      THEN BEGIN    // Load JPEG Image for Display
        JPEGOriginal := TJPEGImage.Create;
        TRY
          JPEGOriginal.LoadFromFile(OpenPictureDialog.Filename);
          ImageOriginal.Picture.Graphic := JPEGOriginal
        FINALLY
          JPEGOriginal.Free
        END;    // Load JPEG Image as Binary Stream
        IF   Assigned(JPEGOriginalBinary)
        THEN JPEGOriginalBinary.Free;
        JPEGOriginalBinary := TMemoryStream.Create;
        JPEGOriginalBinary.LoadFromFile(OpenPictureDialog.Filename);    ButtonEncrypt.Enabled := TRUE;
        EditSeedEncrypt.Enabled := TRUE;
      END
    end;
    procedure TFormCrypt.ButtonEncryptClick(Sender: TObject);
    begin
      EncryptImage
    end;
      

  14.   

    procedure TFormCrypt.ButtonDecryptClick(Sender: TObject);
    begin
      DecryptImage
    end;
    procedure TFormCrypt.CheckBoxStretchClick(Sender: TObject);
    begin
      ImageOriginal.Stretch  := CheckBoxStretch.Checked;
      ImageEncrypted.Stretch := CheckBoxStretch.Checked;
      ImageDecrypted.Stretch := CheckBoxStretch.Checked
    end;
    procedure TFormCrypt.EditSeedEncryptChange(Sender: TObject);
    begin
      EncryptImage
    end;
    procedure TFormCrypt.EditSeedDecryptChange(Sender: TObject);
    begin
      DecryptImage
    end;
    procedure TFormCrypt.LabelLab2Click(Sender: TObject);
    begin
      ShellExecute(0, 'open', pchar('http://www.efg2.com/lab'),
                   NIL, NIL, SW_NORMAL)
    end;
    // Make sure only valid numeric characters are present
    procedure TFormCrypt.EditNumericKeyPress(Sender: TObject;
      var Key: Char);  CONST
        Backspace  = #$08;
    begin
      IF   NOT (Key IN [Backspace, '0'..'9'])
      THEN Key := #$00
    end;
    procedure TFormCrypt.ButtonSaveBINClick(Sender: TObject);
    begin
      IF   SaveDialog.Execute
      THEN JPEGEncryptedBinary.SaveToFile(SaveDialog.Filename)
    end;procedure TFormCrypt.FormCreate(Sender: TObject);
    begin
      SaveDialog.InitialDir := ExtractFilePath( ParamStr(0) )
    end;
    procedure TFormCrypt.ButtonLoadBINClick(Sender: TObject);
      VAR
        BitmapDisplay:  TBitmap;
    begin
      IF   OpenDialog.Execute
      THEN BEGIN
        // Load JPEG Image as Binary Stream
        IF   Assigned(JPEGEncryptedBinary)
        THEN JPEGEncryptedBinary.Free;
        JPEGEncryptedBinary := TMemoryStream.Create;
        JPEGEncryptedBinary.LoadFromFile(OpenDialog.Filename);    // Create "noise" bitmap to display since encrypted file cannot be
        // directly displayed (actually we don't even know if it's a valid
        // JPEG yet).
        BitmapDisplay := CreateNoiseImage(ImageEncrypted.Width, ImageEncrypted.Height);
        TRY
          ImageEncrypted.Picture.Graphic := BitmapDisplay;
        FINALLY
          BitmapDisplay.Free
        END;    DecryptImage
      END;
    end;end.