- function ScreenShot_BitmapResult : TBitmap;
- var
- buffer: array of byte;
- x,y, i: integer;
- Bitmap : TBitmap;
- Stream : TMemoryStream;
- WW : integer;
- begin
- {
- WW forces the thing to Get an image that has an even width, even when its ment to b odd
- this fixes the prob with an odd width.
- }
- if MainViewWidth div 2 = MainViewWidth / 2 then
- WW := MainViewWidth
- else
- WW := MainViewWidth+1;
- SetLength(buffer, (WW * MainViewHeight * 3)+1);
- glReadPixels(0, 0, WW, MainViewHeight, GL_RGB, GL_UNSIGNED_BYTE, Pointer(Cardinal(buffer) {+ 18}));
- i := 0;
- Bitmap := TBitmap.Create;
- Bitmap.Canvas.Brush.Color := TVector3fToTColor(BGColor);
- Bitmap.Width := MainViewWidth;
- Bitmap.Height := MainViewHeight;
- for y := 1 to MainViewHeight do
- for x := 1 to WW do
- begin
- if x <= MainViewWidth then
- Bitmap.Canvas.Pixels[x-1,MainViewHeight-y] := RGB(buffer[(i*3)],buffer[(i*3)+1],buffer[(i*3)+2]);
- inc(i);
- end;
- finalize(buffer);
- Result := Bitmap;
- end;