Forum » » Création-Développement » » Comment capturer un écran en C ?
Posté : 09-03-2014 23:08
void screenCapture()
{
  ;struct Screen *screen = NULL;
UBYTE *buffer = NULL ;
LONG& nbsp;count_pixel = 0 ;
int&n bsp;largeur = 1920 ;
int&n bsp;hauteur = 1080 ;
int&n bsp;profondeur = 32 ;
  ;
buffe r = AllocVecTags( (largeur * hauteur * profo ndeur)/8, AVT_ClearWithValue, 0,TAG_END);
  ; screen = LockPubScreen("Workbench");
  ;
struc t RastPort monrastport;
InitR astPort(&monrastport);
struc t RastPort temprastport;
InitR astPort(&temprastport); &nbs p;
monra stport.BitMap=screen->RastPort.BitMap; /* celle du scree n */
Unloc kPubScreen(NULL, screen);
count _pixel = ReadPixelArray8(&monrastport,0,0,1920,1080,buffer,&t emprastport) ;
print f("count_pixel = %ld \n",count_pixel);
  ;
char& nbsp;fileName[1024];
// &nb sp;strcpy(fileName,"RAM:Capture.JPG");
  ;strcpy(fileName,"RAM:Capture.PNG"); & nbsp;
ILuin t imageName ; &n bsp;
  ;ILenum Format;
  ;
ilIni t();
ilGen Images(1, &imageName);
ilBin dImage(imageName);
// if& nbsp;(profondeur == 8) {Format=IL_LUMINANCE;SaveRawBMP8(I,fileNa me);FreeVec(buffer);return;} as IL_LUMINANCE& nbsp;is bugged in devIL
if&nb sp;(profondeur == 24) Format=IL_RGB;
if&nb sp;(profondeur == 32) Format=IL_RGBA;
ilTex Image(largeur,hauteur,1,profondeur/8,Format,IL_UNSIGNED_BYTE,buffer);
ilEna ble(IL_FILE_OVERWRITE);
if(!i lSaveImage(fileName))
{&nbs p;
  ; printf("ilGetError %d !\n",ilGetError());
  ; FreeVec(buffer); &n bsp;
  ; return;
}&nbs p;
ilDel eteImages(1,&imageName);
  ;
FreeV ec(buffer);
}
Cet article provient de Le site des utilisateurs francophones actuels et futurs d'AmigaOS 4.x
https://amiga-ng.org/viewtopic.php?topic=1821&forum=14