Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Principal > Gráficos
Register FAQ Members List Calendar Guía de estilo Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 18/01/2008
Mike Deet Mike Deet is offline
Miembro
 
Join Date: Nov 2007
Posts: 12
Poder: 0
Mike Deet Va por buen camino
Guardar un type packed record

Ola

eu tenho um type que é um packed record de RGB e tenho um array desse type, eu queria guardar esse array num ficheiro e depois abrir esse ficheiro e guardar no mesmo array.

Type
TCubo=packed record
B,G,R:byte;
end;


CuboRGB:array[0..255,0..255,0..255] of TCubo;

algue me diz umas dicas como fazer isto.

MUCHAS GRACIAS
Reply With Quote
  #2  
Old 18/01/2008
Crandel's Avatar
[Crandel] Crandel is offline
Miembro Premium
 
Join Date: May 2003
Location: Parana, Argentina
Posts: 1,475
Poder: 25
Crandel Va por buen camino
Hola Mike, aprende el uso etiquetas para tu codigo sea mas legible.

La idea es crear un archivo del tipo TCubo, el codigo seria algo asi:

Código Delphi [-]
var
  Archi: file of TCubo;
  i,j,k: integer;
begin
  AssignFile(Archi, 'nombre.dat');
  Rewrite(Archi);
  for i := 0 to 255 do
    for j := 0 to 255 do
      for k := 0 to 255 do
        Write(Archi, CuboRGB[i,j,k]);
  CloseFile(Archi);
end;

Suerte
__________________
[Crandel]
Reply With Quote
  #3  
Old 18/01/2008
jachguate's Avatar
jachguate jachguate is offline
Miembro
 
Join Date: May 2003
Location: Guatemala
Posts: 6,254
Poder: 30
jachguate Va por buen camino
También se puede hacer con un stream:

Código Delphi [-]
type
  TColorRGB = packed record
                B, G, R: byte;
  end;

  TCuboRGB = array[0..255,0..255,0..255] of TColorRGB;

procedure GuardaCubo(const CuboRGB: TCuboRGB);
var
  Arch: TFileStream;
begin
  Arch := TFileStream.Create('c:\datos.dat', fmCreate or fmShareExclusive);
  try
    if Arch.Write(CuboRGB, SizeOf(CuboRGB)) <> SizeOf(CuboRGB) then
      raise Exception.Create('Error al escribir!');
  finally
    Arch.Free;
  end;
end;

procedure LeeCubo(var CuboRGB: TCuboRGB);
var
  Arch: TFileStream;
begin
  Arch := TFileStream.Create('c:\datos.dat', fmOpenRead or fmShareDenyNone);
  try
    if Arch.Read(CuboRGB, SizeOf(CuboRGB)) <> SizeOf(CuboRGB) then
      raise Exception.Create('Error al leer!');
  finally
    Arch.Free;
  end;
end;

Hasta luego.

__________________
Juan Antonio Castillo Hernández (jachguate)
Guía de Estilo | Etiqueta CODE | Búsca antes de preguntar | blog de jachguate
Reply With Quote
  #4  
Old 18/01/2008
Crandel's Avatar
[Crandel] Crandel is offline
Miembro Premium
 
Join Date: May 2003
Location: Parana, Argentina
Posts: 1,475
Poder: 25
Crandel Va por buen camino
Quote:
Originally Posted by jachguate View Post
También se puede hacer con un stream:
sisi, me quedaría con tu solución
__________________
[Crandel]
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problema con type anubis Varios 1 06/05/2007 21:24
type needs finalization henrygale Varios 2 13/02/2007 16:49
Como almaceno un Type Record en binario en un blob de MySQL molarte SQL 2 03/10/2005 20:37
¿Como Guardar un "RECORD" en un campo BLOB? sitrico Conexión con bases de datos 5 29/06/2004 17:32
Type Memo emeritos Conexión con bases de datos 1 07/11/2003 14:40


All times are GMT +2. The time now is 01:52.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi