我不想别人把我的图片拿去用,想加密,望高手指点,

解决方案 »

  1.   

    那你就自己写个格式,别用bitmap格式
      

  2.   

    简单XOR下,用时再XOR回来就行了
      

  3.   

    盒子上有一本图像处理的,最后一章有说,去下载
    如果你要代码,在这里也贴给你: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.