Autor Beitrag
newbie44
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 117

Windows XP, Windows ME
D6 Pers, D7 Enterprise
BeitragVerfasst: Mo 31.01.05 14:29 
Hi,

ich habe neulich ne Dll programmiert, jedoch funtioniert sie komischerweise nicht richtig. sie soll ein vorhandenes Bild immer um die hälfte kleiner machen, da das bild in raw vorliegt und meistens cmyk ist wollte ich jedes vierte byte weglassen, jedoch wird das bild nur abgeschnitten und nicht um die hälfte reduziert

hier mal den code:


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
  function ReduceResolutionProportional(Stream: TMemoryStream; Width,
    Height: Word; ColorDepth: Byte; HeadSize: Int64 = 0): TMemoryStream; stdcall;
resourcestring
  OnEWrongStreamSize = 'Wrong Stream Size (%d, %d)';
  OnEWrongPictureFormat = 'Wrong Picture Format (%d, %d)';
var
  Bytes: Int64;
  i, k: Integer;
  HalfWidth: Word;
begin
  if (Width mod 2 = 1) or (Height mod 2 = 1) then begin
    raise EWrongPictureFormat.Create(Format(OnEWrongPictureFormat, [Width, Height]));
    Exit;
  end;
  Bytes:= Width * Height * ColorDepth + HeadSize;
  if Stream.Size <> Bytes then begin
    raise EWrongStreamSize.Create(Format(OnEWrongStreamSize, [Stream.Size, Bytes]));
    Exit;
  end;
  Stream.Position:= 0;
  Result:= TMemoryStream.Create;
  Result.Position:= 0;
  HalfWidth:= Width div 2;
  for i:= 1 to Height do begin
    if i mod 2 = 0 then
      Stream.Seek(soFromCurrent, ColorDepth * Width);
    for k:= 1 to HalfWidth do begin
      Result.CopyFrom(Stream, ColorDepth);
      Stream.Seek(soFromCurrent, ColorDepth * 2);
    end;
  end;
  Stream.Free;
end;




Wiso geht das nicht?

Ich hoffe Ihr könnt mir helfen

Gruß

Sebby

_________________
Dumm darf man sein, aber zu helfen muss man sich wissen.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 01.02.05 20:59 
wiseo stellst du die Frage hier nochmal, einmal reicht doch?

keine ahnung was du vor hast, aber das Ergebnis durch Pixelweglassen ist eh nicht berauschend. Dafür gibt es bessere Ansaätze, z.B. Suche in: Delphi-Forum, Delphi-Library INTERPOLATION

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)