Autor Beitrag
Bääääär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 15:33 
Hi @ all!

Ich möchte ein Bitmap fester Größe in einer Typisierten Datei speichern. Wie muss ich denn da meinen record definieren, oder geht das evtl gar nicht?

mfg,
Bääääär
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 27.02.07 15:35 
Ich würde es mit einem Array of Byte probieren.
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 15:42 
wie? also
ausblenden Delphi-Quelltext
1:
bild:array[120,120] of array[3] of byte					


Und dann muss ich jeden einzelnen farbwert von jedem einzelnen pixel übernehmen???
das dauert doch ewig, und ist zudem noch nen haufen arbeit. Gibts da keine bessere möglichkeit?

Bääääär
PS: Danke für die schnelle Hilfe. ich muss feststellen, dass dieses Forum hier wirklich eins der Besten seiner Art ist!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 27.02.07 15:44 
ich würde ein TFileStream nehmen...

habe fast genau das gleiche Problem. Und ich werde ein TStream nehmen.
das geht am schnelsten und auch am einfachsten *G*

_________________
MFG
Michael Springwald, "kann kein englisch...."
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 15:54 
ja veilleicht, aber ich will ja noch diverse weitere Daten neben dem Bild speichern. Das Bild ist ein thumbnail, also kjommt noch der pfad zum orginal, ein name, einstellungen, usw.

Und zwei dateien zu nehmen, eine für die bilder und eine für die einstellungen ist doof, weil dann leicht fehler kommen, wenn der user eine falsche einstellungsdatei nimmt, usw.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 27.02.07 16:58 
user profile iconBääääär hat folgendes geschrieben:
das dauert doch ewig, und ist zudem noch nen haufen arbeit. Gibts da keine bessere möglichkeit?
Die Speichergröße des Bildes kannst Du sicher feststellen. Dann machst Du ein eindimensionales Array of Byte, dass genau die selbe Größe hat. Mit dem Befehl Move kannst Du dann einfach ein bisschen Speicher hin und her schieben. :wink:
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 17:27 
achso. das ist natürlich logisch. Tja, auf solche ideen komm ich immer nicht... :(

ich werd mal ein bissl rumprobieren und wenns nicht klappen sollte, dann melde ich mich nochma. Danke für die Ideen!

PS: achso: 120px * 120px * 3 byte = 43200 byte. Richtig? oder hab ich jetzt was übersehen?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 27.02.07 17:38 
Moin!

user profile iconBääääär hat folgendes geschrieben:
achso: 120px * 120px * 3 byte = 43200 byte. Richtig? oder hab ich jetzt was übersehen?

Das hängt natürlich vom Pixelformat des Bitmaps ab (kannste aus der entsprechenden Eigenschaft lesen). ;) Für 24bit ist das also korrekt, sonst nicht. :mahn: ;)

cu

Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 18:01 
wenn ich ein neues bitmap erstelle, also mit var:=TBitmap.create; dann ist das doch 24bit, oder?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 27.02.07 18:08 
Moin!

user profile iconBääääär hat folgendes geschrieben:
wenn ich ein neues bitmap erstelle, also mit var:=TBitmap.create; dann ist das doch 24bit, oder?

Wer garantiert dir das? :nixweiss:

Du kannst es aber durch Zuweisung erzwingen (auch "nachträglich" bei vorhandenen Bildern noch). ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 18:15 
mmh. also ich bekomme bei
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
formate.pas:

type
  TBild=record
    Name:String[255];
    Number:integer;
    mode:byte;
    path:string[255];
    active:boolean;
    thumb:array[0..43200] of byte;
  end;

functions.pas:

procedure setbitmap(bmp:Tbitmap; var arr:formate.Tbild);
begin
move(bmp,arr.thumb,43200);
end;

eine zugriffsverletzung.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 27.02.07 18:27 
Moin!

user profile iconBääääär hat folgendes geschrieben:
mmh. also ich bekomme bei
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
formate.pas:

type
  TBild=record
    Name:String[255];
    Number:integer;
    mode:byte;
    path:string[255];
    active:boolean;
    thumb:array[0..43200] of byte;
  end;

functions.pas:

procedure setbitmap(bmp:Tbitmap; var arr:formate.Tbild);
begin
move(bmp,arr.thumb,43200);
end;

eine zugriffsverletzung.

:hair: Ahrg! :shock: Das ist ja auch nicht die Adresse der Bilddaten, sondern der Klasse auf dem Heap! Mach dich mal über TBitmap.Scanlines[] schlau. :mahn: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 18:32 
uuuuuuch. stimmt.

Also die onlinehilfe gibt mir nicht sehr viel zu scanline her, außer, dass ich damit zeilenweise auf die pixel zugreifen kann.

Kann ich nicht auch einen pointer übergeben?
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 27.02.07 19:21 
du kannst in einem TStream alles speichern was du möchtes.

du musst halt nur ein Header anlegen. wo die einzelne Blöcke gespeichert sind.

du könntest z.b. TReader und TWriter nutzen die helfen extrem auch wenn sie einen entschiedenen nachteilel haben: du speichert damit einen String und möchtes jetzt die länge von diesem String haben ohne die Position zu verändern

_________________
MFG
Michael Springwald, "kann kein englisch...."
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 19:35 
nee, davon kann ich wieder gar nüscht, und mir ist es so lieber.
das muss doch mit einem pointer gehen, aber ich finde nix im i_Net dazu
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 27.02.07 20:03 
Moin!

Kopier ab .Scanlines[0], das passt. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 20:21 
?? HÄ? wie jetzt? :?:
*ratlos* :(
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 27.02.07 20:27 
Moin!

.Scanlines[0] ist ein Zeiger auf das erste Byte der Bilddaten... ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bääääär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 27.02.07 21:07 
ich hab jetzt

move(bmp.scanline[0],arr.thumb,43200); aber er will 'ne variable. und scanline[0] gibt einen pointer zurück, also geht das wohl nicht.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 27.02.07 21:46 
Moin!

ausblenden Delphi-Quelltext
1:
move(bmp.scanline[0]^,arr.thumb,43200);					

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.