Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Mi Mai 15, 2024 00:47

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 5 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Blank Screenshots
BeitragVerfasst: Mi Sep 15, 2004 03:07 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Code:
  1.  
  2. procedure ScreenShotJPG(Filename : string; Compression : integer);
  3. var
  4.   buffer: array of byte;
  5.   i, c, temp: integer;
  6.   f: file;
  7.   t, FN, FN2, FN3 : string;
  8.   SSDir : string;
  9.   JPEGImage: TJPEGImage;
  10.   Bitmap : TBitmap;
  11. begin
  12.   // create the scrnshots directory if it doesn't exist
  13.   SSDir := extractfiledir(Paramstr(0))+'\ScreenShots';
  14.   FN2 := extractfilename(Filename);
  15.   FN2 := copy(FN2,1,length(FN2)-length(Extractfileext(FN2)));
  16.  
  17.  // sys_mkdir
  18.   {$I-}
  19.   CreateDir(SSDir);
  20. //  MkDir(SSDir);
  21.   {$I+}
  22.   FN := SSDir+FN2;
  23.  
  24.   for i := 0 to 999 do
  25.   begin
  26.   t := inttostr(i);
  27.   if length(t) < 3 then
  28.   t := '00'+t
  29.   else
  30.   if length(t) < 2 then
  31.   t := '0'+t;
  32.   if not fileexists(FN+'_'+t+'.jpg') then
  33.   begin
  34.   FN3 := FN+'_'+t+'.jpg';
  35.   break;
  36.   end;
  37.   end;
  38.  
  39.   if FN3 = '' then
  40.   begin
  41.     exit;
  42.   end;
  43.   Bitmap := TBitmap.Create;
  44.   Bitmap := ScreenShot_BitmapResult;
  45.   JPEGImage := TJPEGImage.Create;
  46.   JPEGImage.Assign(Bitmap);
  47.   JPEGImage.CompressionQuality := 100-Compression;
  48.   JPEGImage.SaveToFile(FN3);
  49.  
  50.   {$IfDef HELIOS_CONSOLE}
  51.   Cons.AddMsg('Saved Screenshot ' + extractfilename(FN3));
  52.   {$EndIf}
  53.  
  54.   Bitmap.Free;
  55.   JPEGImage.Free;
  56. end;
  57.  
  58. // =============================================================================
  59. //  glSaveScreen
  60. // =============================================================================
  61. //  Speichert einen Screenshot des aktuellen Pufferinhaltes
  62. // =============================================================================
  63. // A Modifyed version of Son Of Satan's glSaveScreen
  64. function ScreenShot_BitmapResult : TBitmap;
  65. var
  66.  Viewport : array[0..3] of TGLint;
  67.  RGBBits  : PRGBQuad;
  68.  Pixel    : PRGBQuad;
  69.  BMP      : TBitmap;
  70.  Header   : PBitmapInfo;
  71.  x,y      : Integer;
  72.  Temp     : Byte;
  73. begin
  74. glGetIntegerv(GL_VIEWPORT, @Viewport);
  75. GetMem(RGBBits, Viewport[2]*Viewport[3]*4);
  76. glFinish;
  77. glPixelStorei(GL_PACK_ALIGNMENT, 4);
  78. glPixelStorei(GL_PACK_ROW_LENGTH, 0);
  79. glPixelStorei(GL_PACK_SKIP_ROWS, 0);
  80. glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
  81. glReadPixels(0, 0, Viewport[2], Viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, RGBBits);
  82.  
  83. BMP := TBitmap.Create;
  84. BMP.PixelFormat := pf32Bit;
  85. BMP.Width       := Viewport[2];
  86. BMP.Height      := Viewport[3];
  87. GetMem(Header, SizeOf(TBitmapInfoHeader));
  88. with Header^.bmiHeader do
  89.  begin
  90.  biSize        := SizeOf(TBitmapInfoHeader);
  91.  biWidth       := Viewport[2];
  92.  biHeight      := Viewport[3];
  93.  biPlanes      := 1;
  94.  biBitCount    := 32;
  95.  biCompression := BI_RGB;
  96.  biSizeImage   := Viewport[2]*Viewport[3]*4;
  97.  end;
  98. // Rot und Blau vertauschen
  99. Pixel := RGBBits;
  100. for x := 0 to Viewport[2]-1 do
  101.  for y := 0 to Viewport[3]-1 do
  102.   begin
  103.   Temp          := Pixel.rgbRed;
  104.   Pixel.rgbRed  := Pixel.rgbBlue;
  105.   Pixel.rgbBlue := Temp;
  106.   inc(Pixel);
  107.   end;
  108. SetDIBits(Bmp.Canvas.Handle, Bmp.Handle, 0, Viewport[3], RGBBits, TBitmapInfo(Header^), DIB_RGB_COLORS);
  109.  
  110. FreeMem(Header);
  111. FreeMem(RGBBits);
  112. Result := BMP;
  113. end;
  114.  


Sometimes screenshots are compleatly blank(with no known patern of why they go blank).

Below is 2 screenshots, 1 taken by the program and the other taken by windows(since the program just created a blank image), all thats different about the 2 is the cameras Y position.

FYI: The map is FFA5.bsp from Jedi Knight: Jedi Academy


Dateianhänge:
Dateikommentar: Taken By Helios
_0067.jpg [236.9 KiB]
71-mal heruntergeladen
Dateikommentar: Taken By Windows
ds.jpg [211.29 KiB]
71-mal heruntergeladen

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Sep 16, 2004 02:36 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
I also get blank screenshots when trying to take a screenshot of the loading screen when its progressed alot (over 50%). The background is rendered at the start, and the progress bar is then rendered ontop each time its refreshed (The frame isn't cleared at the start, so the background doesn't need to be re-drawn)

Pic attached is the start of the loading screen, nothing except header information and lumps(its a q3 map) has been loaded.


Dateianhänge:
Dateikommentar: Loading screen at 0%
Helios_006.jpg [142.27 KiB]
52-mal heruntergeladen

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Sep 16, 2004 10:01 
Offline
DGL Member
Benutzeravatar

Registriert: Mo Sep 23, 2002 19:27
Beiträge: 5812
Programmiersprache: C++
What do you mean by "blank"? Is the whole screenshot just black? If that's the case, then the problem maybe your hardware/drivers. I remember that older ATI-drivers together with newer ATI-cards produced black screenshots when AA was enabled. But besides this, I can't think of a reaon why the code I gave you wouldn't work. But maybe you changed the read buffer to read from a wrong buffer by accident?

_________________
www.SaschaWillems.de | GitHub | Twitter | GPU Datenbanken (Vulkan, GL, GLES)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Sep 16, 2004 15:39 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Blank as in pure white.

I have a Nvidia card, and the drivers arn't the most uptodate but they should be higher thann the drivers that came with the card. Geforce 4 ti4200. But since the thing produces screenshots sometimes i can't see it being eather a wrong buffer(especialy since the code is exactly the same as urs except it shoves the bitmap out as a result) or it being a driver error.

Anyone have Quake3, Return To Castle Wolfenstine, Jedi Knight: Jedi Academy? If so i could post the basic engine - game files, and whoever has the games, could extract all the files from the PK3's (which are ZIP's but named pk3....) and shove them in the same dir as the engine. (thus testing if its a local problem here, or "world wide")

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Sep 18, 2004 04:02 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Adding

Code:
  1.  
  2. SwapBuffers(h_DC);
  3.  


after glfinish; seems to have fixed the problem....

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 5 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 8 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.058s | 18 Queries | GZIP : On ]