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:
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.