Debian Codegraph @

src/graphic.cpp

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /***************************************************************************
2 graphic.cpp - description
3 -------------------
4 begin : Sat Oct 14 2000
5 copyright : (C) 2000 by Waldemar Baraldi
6 email : [email protected]
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "graphic.h"cxx . . $ `<file>/src/graphic.h`/
19 #include <stdlib.h>
20
21 Graphiccxx . . $ Graphic#::Graphiccxx . . $ Graphic#Graphic(49f6e7a06ebc5aa8).():Surfacecxx . . $ Surface#(){
22 pixelscxx . . $ Graphic#pixels.=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
23 clip_activecxx . . $ Graphic#clip_active.=false;
24 };
25
26 Graphiccxx . . $ Graphic#::Graphiccxx . . $ Graphic#Graphic(3e454b8ccf442868).(int width, int height)
27 :Surfacecxx . . $ Surface#(width, height){
28 pixelscxx . . $ Graphic#pixels.=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
29 clip_activecxx . . $ Graphic#clip_active.=false;
30 }
31
32 Graphiccxx . . $ Graphic#::Graphiccxx . . $ Graphic#Graphic(1507bd8ff93ab3fd).(Graphiccxx . . $ Graphic# * g){
33 pixelscxx . . $ Graphic#pixels.= malloccxx . . $ malloc(9f008b2a9698428b).(g->surfacecxx . . $ Surface#surface.->w*g->surfacecxx . . $ Surface#surface.->h*g->surfacecxx . . $ Surface#surface.->format->BytesPerPixel);
34 memcpy(pixelscxx . . $ Graphic#pixels., g->surfacecxx . . $ Surface#surface.->pixels,g->surfacecxx . . $ Surface#surface.->w*g->surfacecxx . . $ Surface#surface.->h*g->surfacecxx . . $ Surface#surface.->format->BytesPerPixel);
35
36 surfacecxx . . $ Surface#surface.=SDL_CreateRGBSurfaceFrom(pixelscxx . . $ Graphic#pixels.,
37 g->surfacecxx . . $ Surface#surface.->w, g->surfacecxx . . $ Surface#surface.->h, g->surfacecxx . . $ Surface#surface.->format->BitsPerPixel,
38 g->surfacecxx . . $ Surface#surface.->pitch, g->surfacecxx . . $ Surface#surface.->format->Rmask, g->surfacecxx . . $ Surface#surface.->format->Gmask,
39 g->surfacecxx . . $ Surface#surface.->format->Bmask, g->surfacecxx . . $ Surface#surface.->format->Amask);
40 clip_activecxx . . $ Graphic#clip_active.=false;
41 }
42
43 Graphiccxx . . $ Graphic#::~cxx . . $ Graphic#`~Graphic`(ced63f7c635d850d).Graphiccxx . . $ Graphic#(){
44 if (pixelscxx . . $ Graphic#pixels.) freecxx . . $ free(bd21765a0afc8e3c).(pixelscxx . . $ Graphic#pixels.);
45 }
46
•47 void Graphiccxx . . $ Graphic#::setAlphacxx . . $ Graphic#setAlpha(44b6ea1973a07080).(char value){
48 SDL_SetAlpha(surfacecxx . . $ Surface#surface., SDL_SRCALPHAcxx . . $ `<external>/3508485105195885937/SDL_video.h:247:9`!, value);
49 }
50
•51 void Graphiccxx . . $ Graphic#::enableClippingcxx . . $ Graphic#enableClipping(b45ddcbc8423892c).(bool flag){
52
53 if (flag){
54 SDL_Rect rect;
55 rect.x=clip_xcxx . . $ Graphic#clip_x.;
56 rect.y=clip_ycxx . . $ Graphic#clip_y.;
57 rect.w=clip_widthcxx . . $ Graphic#clip_width.;
58 rect.h=clip_heightcxx . . $ Graphic#clip_height.;
59 SDL_SetClipRect(surfacecxx . . $ Surface#surface., &rect);
60 }else
61 SDL_SetClipRect(surfacecxx . . $ Surface#surface., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
62 }
63
64 void Graphiccxx . . $ Graphic#::setClippingcxx . . $ Graphic#setClipping(748afa4755bc9595).(int x, int y, int width, int height){
65 clip_ycxx . . $ Graphic#clip_y.=y;
66 clip_xcxx . . $ Graphic#clip_x.=x;
67 clip_widthcxx . . $ Graphic#clip_width.=width;
68 clip_heightcxx . . $ Graphic#clip_height.=height;
69 }
70
•71 void Graphiccxx . . $ Graphic#::flipcxx . . $ Graphic#flip(cf90abbfd5bcb432).(Axiscxx . . $ Axis# a){
72 if (surfacecxx . . $ Surface#surface.){
73 if (SDL_MUSTLOCKcxx . . $ `<external>/3508485105195885937/SDL_video.h:250:9`!(surface))
74 if (SDL_LockSurface(surfacecxx . . $ Surface#surface.)<0) return;
75 int i,j,width=surfacecxx . . $ Surface#surface.->w, height=surfacecxx . . $ Surface#surface.->h, aw,bw;
76 Uint32cxx . . $ Uint32# * p, *q, aux, *ap;
77 p=(Uint32cxx . . $ Uint32#*)(surfacecxx . . $ Surface#surface.->pixels);
78 if (a==HAxiscxx . . $ HAxis.){
79 q=p+width*height-1;
80 height/=2;
81 for (j=0;j<height;j++){
82 for (i=0;i<width;i++){
83 aux=*p;
84 *p++=*q;
85 *q--=aux;
86 }
87 }
88 }
89 else{
90 aw=width>>1;
91 bw=width-1;
92 for (j=0;j<height;j++){
93 ap=p;
94 q=p+bw;
95 for (i=0;i<aw;i++){
96 aux=*p;
97 *p++=*q;
98 *q--=aux;
99 }
100 p=ap+width;
101 }
102 }
103 if (SDL_MUSTLOCKcxx . . $ `<external>/3508485105195885937/SDL_video.h:250:9`!(surface))
104 SDL_UnlockSurface(surfacecxx . . $ Surface#surface.);
105 }
106 }
107
108 void Graphiccxx . . $ Graphic#::fillcxx . . $ Graphic#fill(b1146eedae1e1d0b).(int r, int g, int b){
109 SDL_FillRect(surfacecxx . . $ Surface#surface., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, SDL_MapRGB(surfacecxx . . $ Surface#surface.->format, r, g, b));
110 }
111
112 void Graphiccxx . . $ Graphic#::fillRectcxx . . $ Graphic#fillRect(399580efc014f2ba).(int x, int y, int w, int h, int r, int g, int b, int a){
113 SDL_Rect rect;
114
115 rect.x=x;
116 rect.y=y;
117 rect.w=w;
118 rect.h=h;
119
120 SDL_FillRect(surfacecxx . . $ Surface#surface., &rect, SDL_MapRGBA(surfacecxx . . $ Surface#surface.->format, r, g, b, a));
121 }
122