Eduard
2012-12-28 17:03:53
Hello Guys,
I'm experimenting with a huge project that i'm coding. Before I'm releasing anything I would like to experiment with SRL/SCAR and it's coding efficiency a bit.
I currently (for fun purphoses) wrote a bitmap creator that creates a bitmap from the client, read's it pixel by pixel(on purphose) and creates a negative effect and then writes it to the debug window.
So, the psuedo working of the script is the following:
- GetClientDimension
- Scan the whole screen scanning the X-as first. Then when the Max X width is given do + Y. Actually scanning every pixel on the screen.
- Whilst reading the screen, convert the pixel to RGB and write the RGB to a color modifying the RGB colors by doing 255-R/G/B etc. Creating a negative effect.
- When done reading the client dimensions save file to bitmap
Problems:
It's quite slow. I would like to know how to fasten up the GetColor(x,y) process manually. Can it be faster?
Thanks,
Eduard
I'm experimenting with a huge project that i'm coding. Before I'm releasing anything I would like to experiment with SRL/SCAR and it's coding efficiency a bit.
I currently (for fun purphoses) wrote a bitmap creator that creates a bitmap from the client, read's it pixel by pixel(on purphose) and creates a negative effect and then writes it to the debug window.
program DrawNegativeClient;
var
x, y: integer;
ClientHeight, ClientWidth: integer;
BitmapClient: integer;
const
Savepath = 'C:\Users\Eduard\Desktop\MyBitmap.bmp';
procedure GetClientRes;
begin
//SetDesktopAsClient;
GetClientDimensions(ClientWidth,ClientHeight);
writeln('Height: '+inttostr(ClientHeight)+' Width: '+inttostr(ClientWidth)+'');
end;
procedure CreateBitmapFromScreen;
begin
BitmapClient:= CreateBitmap(ClientWidth,ClientHeight);
end;
procedure BitmapToDebugCanvas;
var
MyDebugCanvas: TCanvas;
begin
DisplayDebugImgWindow((ClientWidth),(ClientHeight));
DrawBitmapDebugImg(BitmapClient);
end;
procedure PixelOutputNegative;
var
R,G,B,NegativePixel, PixelFromScreen: integer;
begin
NegativePixel:= 0;
PixelFromScreen:= GetColor(x,y);
ColorToRGB(PixelFromScreen,R,G,B);
NegativePixel:= RGBToColor((255-R),(255-G),(255-B));
FastSetPixel(BitmapClient,x,y,NegativePixel);
end;
procedure RegisterEveryPixelOnScreen;
begin
y:= 0;
repeat
x:= 0;
while(x <= (ClientWidth - 1)) do
begin
PixelOutputNegative;
x:= x + 1;
end;
y:= y + 1;
until(y >= (ClientHeight-1))
end;
begin
ClearDebug;
GetClientRes;
CreateBitmapFromScreen;
RegisterEveryPixelOnScreen;
BitmapToDebugCanvas;
SaveBitmap(BitmapClient,SavePath);
FreeBitmap(BitmapClient);
end.So, the psuedo working of the script is the following:
- GetClientDimension
- Scan the whole screen scanning the X-as first. Then when the Max X width is given do + Y. Actually scanning every pixel on the screen.
- Whilst reading the screen, convert the pixel to RGB and write the RGB to a color modifying the RGB colors by doing 255-R/G/B etc. Creating a negative effect.
- When done reading the client dimensions save file to bitmap
Problems:
It's quite slow. I would like to know how to fasten up the GetColor(x,y) process manually. Can it be faster?
Thanks,
Eduard