fixed errors in MM rendering

This commit is contained in:
zueuk 2006-04-05 11:01:07 +00:00
parent d85cf9e346
commit 4f76d9b2a3
4 changed files with 59 additions and 62 deletions

View File

@ -47,7 +47,6 @@ type
FImageMaker: TImageMaker;
procedure InitValues;
procedure InitBuffers;
procedure ClearBuffers;
@ -75,7 +74,7 @@ type
procedure Render; override;
function GetImage: TBitmap; override;
procedure UpdateImage(CP: TControlPoint); override;
// procedure UpdateImage(CP: TControlPoint); override;
procedure SaveImage(const FileName: String); override;
end;
@ -212,6 +211,8 @@ begin
Bucketwidth := oversample * fcp.Width + 2 * max_gutter_width;
BucketSize := BucketWidth * BucketHeight;
assert(BucketSize > 0); // who knows ;)
if high(buckets) <> (BucketSize - 1) then
try
SetLength(buckets, BucketSize);
@ -219,6 +220,7 @@ begin
on EOutOfMemory do begin
Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48);
FStop := true;
exit;
end;
end;
@ -226,17 +228,6 @@ begin
FImageMaker.SetBucketData(Buckets, BucketWidth);
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64.InitValues;
begin
InitBuffers;
CreateCamera;
CreateColorMap;
fcp.Prepare;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64.SetPixels;
var
@ -245,7 +236,6 @@ var
nrbatches: Integer;
IterateBatchProc: procedure of object;
begin
Prepare;
Randomize;
if FCP.FAngle = 0 then begin
@ -290,7 +280,13 @@ begin
FImageMaker.SetCP(FCP);
FImageMaker.Init;
InitValues;
InitBuffers;
if FStop then exit; // memory allocation error
CreateColorMap;
Prepare;
CreateCamera;
ClearBuffers;
SetPixels;
@ -302,6 +298,7 @@ begin
end;
///////////////////////////////////////////////////////////////////////////////
{
procedure TRenderer64.UpdateImage(CP: TControlPoint);
begin
FCP.background := cp.background;
@ -317,6 +314,7 @@ begin
FImageMaker.OnProgress := OnProgress;
FImageMaker.CreateImage;
end;
}
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64.SaveImage(const FileName: String);

View File

@ -54,7 +54,6 @@ type
FImageMaker: TImageMaker;
procedure InitValues;
procedure InitBuffers;
procedure ClearBuffers;
@ -223,6 +222,7 @@ begin
on EOutOfMemory do begin
Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48);
FStop := true;
exit;
end;
end;
@ -230,17 +230,6 @@ begin
FImageMaker.SetBucketData(Buckets, BucketWidth);
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64MT.InitValues;
begin
InitBuffers;
CreateCamera;
CreateColorMap;
fcp.Prepare;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64MT.SetPixelsMT;
var
@ -278,6 +267,12 @@ begin
end;
end;
{ for i := 0 to NrOfTreads - 1 do
begin
WorkingThreads[i].Terminate;
WorkingThreads[i].Free;
end;}
DeleteCriticalSection(CriticalSection);
Progress(1);
end;
@ -314,7 +309,14 @@ begin
FImageMaker.SetCP(FCP);
FImageMaker.Init;
InitValues;
InitBuffers;
if FStop then exit; // memory allocation error
CreateColorMap;
fcp.Prepare;
CreateCamera;
ClearBuffers;
SetPixelsMT;

View File

@ -34,7 +34,6 @@ type
Slice, nrSlices: integer;
procedure InitValues;
procedure InitBuffers;
procedure CreateCamera;
@ -43,7 +42,7 @@ type
function GetNrSlices: integer; override;
public
function GetImage: TBitmap; override;
function GetImage: TBitmap; override;
procedure SaveImage(const FileName: String); override;
procedure Render; override;
@ -124,6 +123,7 @@ begin
on EOutOfMemory do begin
Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48);
FStop := true;
exit;
end;
end;
@ -131,20 +131,6 @@ begin
FImageMaker.SetBucketData(Buckets, BucketWidth);
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64.InitValues;
begin
image_height := fcp.Height;
image_Width := fcp.Width;
CreateCamera;
InitBuffers;
CreateColorMap;
fcp.Prepare;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64.Render;
const
@ -160,7 +146,7 @@ begin
image_Center_Y := fcp.center[1];
image_height := fcp.Height;
image_Width := fcp.Width;
image_width := fcp.Width;
oversample := fcp.spatial_oversample;
// entered memory - imagesize
@ -168,8 +154,10 @@ begin
ApproxMemory := 32 * oversample * oversample * image_height * image_width;
if (MaxMemory < 0) then
Exit;
assert(MaxMemory > 0);
if MaxMemory <= 0 then exit;
// All this 'dividers' stuff looks very VERY weird! :-\
nrSlices := 1 + ApproxMemory div MaxMemory;
@ -200,7 +188,12 @@ begin
zoom_scale := power(2.0, fcp.zoom);
center_base := center_y - ((nrslices - 1) * fcp.height) / (2 * fcp.pixels_per_unit * zoom_scale);
InitValues;
image_height := fcp.Height;
image_width := fcp.Width;
InitBuffers;
CreateColorMap;
Prepare;
for i := 0 to NrSlices - 1 do begin
if FStop then
@ -208,8 +201,10 @@ begin
Slice := i;
fcp.center[1] := center_base + fcp.height * slice / (fcp.pixels_per_unit * zoom_scale);
CreateCamera;
ClearBuffers;
SetPixels;
if not FStop then begin

View File

@ -22,19 +22,18 @@ unit RenderMM_MT;
interface
uses
Windows, Graphics,
Windows, Forms, Graphics,
Render64MT, Controlpoint, ImageMaker, BucketFillerThread, XForm;
type
TRendererMM64_MT = class(TRenderer64MT)
private
image_Width, image_Height: integer;
image_Width, image_Height: int64;
image_Center_X, image_Center_Y: double;
Slice, nrSlices: integer;
procedure InitValues;
procedure InitBuffers;
procedure CreateCamera;
@ -118,23 +117,21 @@ begin
Bucketwidth := oversample * image_width + 2 * gutter_width;
BucketSize := BucketWidth * BucketHeight;
if high(buckets) <> (BucketSize - 1) then begin
if high(buckets) <> (BucketSize - 1) then
try
SetLength(buckets, BucketSize);
except
on EOutOfMemory do begin
Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48);
FStop := true;
exit;
end;
end;
// share the buffer with imagemaker
FImageMaker.SetBucketData(Buckets, BucketWidth);
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64_MT.InitValues;
begin
image_height := fcp.Height;
image_Width := fcp.Width;
inherited;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64_MT.Stop;
var
@ -216,7 +213,12 @@ begin
zoom_scale := power(2.0, fcp.zoom);
center_base := center_y - ((nrslices - 1) * fcp.height) / (2 * fcp.pixels_per_unit * zoom_scale);
InitValues;
image_height := fcp.Height;
image_Width := fcp.Width;
InitBuffers;
CreateColorMap;
fcp.Prepare;
for i := 0 to NrSlices - 1 do begin
if FStop then