Yes.
I needed to edit the gems, so I needed the grid.
And I didn't want to always copy-n-paste those help grids.
This grids function makes life much more easier when you need grids. QUICK_EDIT
The main code, in TFrmSHPImage.RefreshImage1 in FormSHPImage, add this after or before the show_center stuff:
Code:
if show_grid then // Create Grid -pd
begin
r:=-1;
for x:=SHPData^.SHP.Header.Width div 2 downto -30 do
begin
y:=abs((x div 2)-(SHPData^.SHP.Header.Width div 4))+((SHPData^.SHP.Header.Height) div 2)-1;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[x*Zoom,y*Zoom]);
image1.Picture.Bitmap.Canvas.FillRect(Rect((x*Zoom),(y*Zoom),(x*Zoom)+Zoom,(y*Zoom)+Zoom));
r:=r+1;
if (r mod 30=0) and (r>0) then
begin
r:=0;
x2:=x;
y2:=y;
c:=y-(x div 2);
while y2<SHPData^.SHP.Header.Height do
begin
y2:=(x2 div 2)+c;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[x2*Zoom,y2*Zoom]);
image1.Picture.Bitmap.Canvas.FillRect(Rect((x2*Zoom),(y2*Zoom),(x2*Zoom)+Zoom,(y2*Zoom)+Zoom));
x2:=x2+1;
end;
end;
end;
r:=-1;
for x:=SHPData^.SHP.Header.Width div 2 to SHPData^.SHP.Header.Width+30 do
begin
y:=abs((x div 2)-(SHPData^.SHP.Header.Width div 4))+((SHPData^.SHP.Header.Height) div 2)-1;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[x*Zoom,y*Zoom]);
image1.Picture.Bitmap.Canvas.FillRect(Rect((x*Zoom),(y*Zoom),(x*Zoom)+Zoom,(y*Zoom)+Zoom));
r:=r+1;
if (r mod 30=0) and (r>0) then
begin
r:=0;
x2:=x;
y2:=y;
c:=y+(x div 2);
while y2<SHPData^.SHP.Header.Height do
begin
y2:=-(x2 div 2)+c;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[x2*Zoom,y2*Zoom]);
image1.Picture.Bitmap.Canvas.FillRect(Rect((x2*Zoom),(y2*Zoom),(x2*Zoom)+Zoom,(y2*Zoom)+Zoom));
x2:=x2-1;
end;
end;
end;
end;
Don't forget to declare variables in that proc:
Code:
x,y,r,x2,y2,c:integer;
I think that's all.
As said, possibly, the main algorithm could be a slightly optimized.
The main idea turned out to be the fastest. QUICK_EDIT
I just optimized the algorithms for show_center and show_grid.
There are more variables now...
Code:
x,y,r,x2,y2,c,xZ,yZ,xdiv2:integer;
...but only half as many calculation (speeds the whole thing up, result is noticeable):
Code:
if show_center then // Create Cross
for x := 0 to SHPData^.SHP.Header.Width -1 do
for y := 0 to SHPData^.SHP.Header.Height-1 do
if (x = (SHPData^.SHP.Header.Width-1) div 2) or (y = (SHPData^.SHP.Header.Height-1) div 2) then
begin
xZ:=x*Zoom;
yZ:=y*Zoom;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[xZ,yZ]);
image1.Picture.Bitmap.Canvas.FillRect(Rect(xZ,yZ,xZ+Zoom,yZ+Zoom));
end;
if show_grid then // Create Grid -pd
begin
r:=-1;
for x:=SHPData^.SHP.Header.Width div 2 downto -30 do
begin
xdiv2:=x div 2;
y:=abs(xdiv2-(SHPData^.SHP.Header.Width div 4))+((SHPData^.SHP.Header.Height) div 2)-1;
xZ:=x*Zoom;
yZ:=y*Zoom;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[xZ,yZ]);
image1.Picture.Bitmap.Canvas.FillRect(Rect(xZ,yZ,xZ+Zoom,yZ+Zoom));
r:=r+1;
if (r mod 30=0) and (r>0) then
begin
r:=0;
x2:=x;
y2:=y;
c:=y-xdiv2;
while y2<SHPData^.SHP.Header.Height do
begin
y2:=(x2 div 2)+c;
xZ:=x2*Zoom;
yZ:=y2*Zoom;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[xZ,yZ]);
image1.Picture.Bitmap.Canvas.FillRect(Rect(xZ,yZ,xZ+Zoom,yZ+Zoom));
x2:=x2+1;
end;
end;
end;
r:=-1;
for x:=SHPData^.SHP.Header.Width div 2 to SHPData^.SHP.Header.Width+30 do
begin
y:=abs((x div 2)-(SHPData^.SHP.Header.Width div 4))+((SHPData^.SHP.Header.Height) div 2)-1;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[x*Zoom,y*Zoom]);
image1.Picture.Bitmap.Canvas.FillRect(Rect((x*Zoom),(y*Zoom),(x*Zoom)+Zoom,(y*Zoom)+Zoom));
r:=r+1;
if (r mod 30=0) and (r>0) then
begin
r:=0;
x2:=x;
y2:=y;
c:=y+(x div 2);
while y2<SHPData^.SHP.Header.Height do
begin
y2:=-(x2 div 2)+c;
image1.Picture.Bitmap.Canvas.Brush.Color := OpositeColour(image1.Picture.Bitmap.Canvas.Pixels[x2*Zoom,y2*Zoom]);
image1.Picture.Bitmap.Canvas.FillRect(Rect((x2*Zoom),(y2*Zoom),(x2*Zoom)+Zoom,(y2*Zoom)+Zoom));
x2:=x2-1;
end;
end;
end;
OK, before, I still got an improvement
*me = perfectionist*
Change the
xZ:=x*Zoom;
yZ:=y*Zoom;
to
xZ:=(x-1)*Zoom;
yZ:=(y-1)*Zoom;
(remember to do this for both!)
It will make the grid being aligned better.
And I just forgot that there's a menu entry for "Show Center", so there should also be one for "Show Grid".
I've also been reminded that this is only the RA2 cell size, maybe a TS one would be useful as well. QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Sun Jul 24, 2005 6:19 am Post subject:
I've implemented your stuff here and tested it, PaD.
I made few changes in order to make it support RA2 and TS Grids.
It worked on some SHPs (specially small ones), and caused infinite loops on other bigger ones. This part, I've fixed, so I'm ready to release a new version with it.
Code:
while y2<SHPData^.SHP.Header.Height do
begin
y2:=-(x2 div 2)+c;
(The y2 above could receive some negative values and this would cause an infinite loop, since the condition in the while would never be reached)
However, the grids are not looking fully cool on these big images. I'm gonna be releasing the OS SHP Builder 3.33 soon, so we can get fixing it with the community feedback. _________________
Mods, Mods Support, Public Researchs, Map Archives, Tutorials, A Friendly Community and much more. Check it out now! QUICK_EDIT
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum