Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Encode string of bits > BMP

[es] :: Pascal / Delphi / Kylix :: Encode string of bits > BMP

[ Pregleda: 465 | Odgovora: 1 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Divjak
Vladimir Divjak

Član broj: 4783
Poruke: 535
*.zrenjanin.beotel.net.



Profil

icon Encode string of bits > BMP06.02.2005. u 19:44

Da li neko zna gde bih mogao da nadjem nesto o tematici encodovanja texta u bmp?
Znaci kako bih mogao da txt fajl koji izgleda recimo
0 0 0
0 0 0
0 0 0
pretvorim u Windows BitMap-u 3x3 px svi crne boje?

(u vezi sa temom http://www.elitesecurity.org/tema/odgovor/93788)
And don't be mad at me for crying for humanity,
call it pretensions but I got good intentions,
to keep my sanity, I'm hoping, fuck, there's gotta be
an answer to their strategies and their evil inventions... ~Looptroop
06.02.2005. u 19:44 

IgLo
Igor Lovric
Sremski Karlovci

Član broj: 19524
Poruke: 128
*.neobee.net.

Sajt: lovric.narod.ru


Profil

icon Re: Encode string of bits > BMP07.02.2005. u 13:10
Evo ga jedan primer koji radi sa takvom slikom bilo koje dimenzije. Stavi jedan Button na form i za OnClick ubaci sledecu proceduru. Obrati paznju da uticava fajl "C:\IMAGE.TXT". 0 ti je crna boja, 1 je bela, a sve ostalo je transparentno. Umesto Form1.Canvas.Draw(10, 10, B); vec sam ubaci sta hoces da uradis sa slikom, ovo sam cisto radi testa stavio.

Code:

procedure TForm1.BitBtn1Click(Sender: TObject);

Var
  F : TextFile;
  B : TBitMap;

  S : String;
  X,
  Y : Integer;

begin
  AssignFile (F, 'c:\image.txt');
  {$I-}
  Reset (F);
  {$I+}
  If IOResult <> 0 Then
    MessageDlg('Can''t open file c:\image.txt', mtWarning, [mbOK], 0)
  Else
    Begin
      Y := 0;
      B := TBitmap.Create;
      B.Transparent := True;
      B.TransparentColor := clFuchsia;
      B.TransparentMode :=tmFixed;
      While Not Eof (F) Do
        Begin
          ReadLn (F, S);
          B.Height := B.Height + 1;
          If B.Width < Length (S) Then
            B.Width := Length (S);
          For X := 1 To Length (S) Do
            Begin
              Case S [x] Of
                '0' : B.Canvas.Pixels [x - 1, y] := clBlack;
                '1' : B.Canvas.Pixels [x - 1, y] := clWhite;
              Else
                B.Canvas.Pixels [x - 1, y] := clFuchsia;
              End;
            End;
          Inc (Y);
        End;
      CloseFile (F);
      Form1.Canvas.Draw(10, 10, B);
      B.Destroy;
    End;
end;
07.02.2005. u 13:10 

[es] :: Pascal / Delphi / Kylix :: Encode string of bits > BMP

[ Pregleda: 465 | Odgovora: 1 ]

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.