K .
N it h e e s h M u r r u g a n
W h a t is a D e v ic e C o n t e x t ?
A d e vic e c o ntex t is a str u ctu r e t h at d efi n e s a s e t of gra p hic o bj e cts a n d t h eir a s s o ci at e d attri b u t e s, a s w ell as th e gra p hic m o d e s t h at a ffe c t o u t p u t .
W h a t is a D e v ic e C o n t e x t ?
T h e g r a p h i c o b j e c t s in c l u d e
a p e n fo r li n e d r a w i n g , a b r u s h fo r p a in t in g a n d a bit m a p for c o p yi n g p a r ts o f th e sc re e n , a p al ette for d efi ni n g a v a ila b le c o lo r s a r e gi o n f o r cli p p i n g o p e r a t io n s , a n d a p at h for p ai nti n g a o p e r a t io n s . fillin g , o r s c r olli n g the and nd set of
oth er
dra wing
W h y w e g o fo r D e v ic e C o n t e x t ?
O n e of the ad va ntage of W i n d o w s Progra m ming is to co ntrol th e d e v ic e .
i. e ) D e v i c e in d e p e n d e n c e .
A p plic ati o n s c a n dra w a n d p ri nt o u t p u t o n a v a r ie t y o f d e v ic e s .
W h y w e g o fo r D e v ic e C o n t e x t ?
D e vice In d e p e n d e n c e is su p p orte d i n w i n d o w s b a s e d o n t h e t w o fil e ty p e s .
G d i.d ll D e v ic e D r iv e r
W h y w e g o fo r D e v ic e C o n t e x t ?
G D I is G r a p h i c s D e v i c e In t e r f a c e . D e vic e Driv er d e p e n d s o n t h e d e vic e o r th e a p p lic a t io n w h ic h w o r k s o n . F o r e x a m p le : if t h e a p p li c a tio n d r a w s o u t p u t i n t h e cli e n t a r e a o f its w i n d o w o n a V G A d i s p l a y , t h i s li b r a r y is V g a . d l l ; if t h e a p p li c a tio n p ri n t s o u t p u t o n a n E p s o n F X - 8 0 p r i n t e r, t h i s l i b r a r y i s E p s o n 9 .d ll.
H o w it w o r k s ?
A n a p plic ati o n m u st i nfo r m G D I t o l o a d a p a r t i c u l a r d e v i c e d r i v e r. o n c e t h e driver is lo a d e d, th e d ri v e r w ill p r e p a r e t h e d e vi c e f o r d r a w in g o p e r a t io n s . T h e s e tas ks are acc o m plis h e d b y cr e ati n g a n d m a i nt ai ni n g a d e vic e c o n te x t (D C ).
H o w it w o r k s ?
U nlike m o st of t h e str u ctu r e s, a n a p plic ati o n n e v e r h a s dir e ct a c c e s s to th e D C . It op erates on the str uct ure in dire ctly by c a lli n g v ari o u s fu n c t io n s .
W h o a r e a ll W o r k in g ?
G r a p h ic O b je c t A s s o c ia te d a tt r ib u te s
Bit m a p
Size , in b y t e s ; d i m e n s i o n s , in p i x e l s ; c o l o r fo r m a t ; c o m p r e s s io n s c h e m e ; a n d s o o n .
Br u s h P a le tte Fo n t Pa th Pe n Re g i o n
St y l e , c o l o r, p a t t e r n , a n d o r i g i n . Co l o r s a n d s i ze ( o r n u m b e r o f c o l o r s ) . Ty p e fa c e n a m e , w id t h , h e ig h t , w e ig h t , ch a ra c te r se t, a n d so o n . Sh a p e . St y l e , w i d t h , a n d c o l o r. Lo c a t i o n a n d d i m e n s i o n s .
W h o a r e a ll W o r k in g ?
G ra p h ic s m o d e Ba c k g r o u n d D e s c r ip t io n D e f in e s h o w b a c k g r o u n d c o lo r s a r e m ix e d w i t h e x i s t i n g w i n d o w o r s c r e e n c o l o r s fo r b it m a p a n d te x t o p e r a t io n s . D e f i n e s h o w fo r e g r o u n d c o l o r s a r e m i x e d w i t h e x i s t i n g w i n d o w o r s c r e e n c o l o r s fo r p e n , b r u s h , b it m a p , a n d te x t o p e r a t io n s . D e f i n e s h o w g r a p h i c s o u t p u t is m a p p e d f r o m lo g i c a l ( o r w o r l d ) s p a c e o n t o t h e w i n d o w , s c r e e n , o r p r i n t e r p a p e r. D e f i n e s h o w t h e b r u s h p a t t e r n is u s e d t o f i l l t h e in t e r i o r o f c o m p l e x r e g i o n s . D e f in e s h o w b it m a p c o lo r s a r e m ix e d w it h e x is t in g w in d o w o r s c r e e n c o lo r s w h e n th e b i t m a p is c o m p r e s s e d ( o r s c a l e d d o w n ) .
D r a w in g
M a p p in g
P o ly g o n - f ill
St r e t c h i n g
Ty p e s o f D C
T h e r e a r e f o u r t y p e s o f D Cs :
D is p la y P r in t e r M e m o r y (o r c o m p a t ib le ) , a n d In fo r m a t io n .
E a c h ty p e s e r v e s a s p e c if ic p u r p o s e
W h at D C D o es?
D e v ic e c o n t e x t D is p la y D e s c r ip t io n Su p p o r t s d r a w i n g o p e ra t io n s o n a v id e o d is p la y . Su p p o r t s d r a w i n g o p e ra t io n s o n a p r in t e r o r p l o t t e r. Su p p o r t s d r a w i n g o p e ra t io n s o n a b it m a p . Su p p o r t s t h e r e t r i e v a l o f d e v ic e d a ta .
P r in t e r
M e m o ry In f o r m a t i o n
H o w D C O p e ra te s ?
An a p plic ati o n ca n p erfor m the foll o w i n g o p e ra t io n s o n a d e v ic e c o n te x t : E n u m e r a t e e x is t in g g r a p h ic o b je c t s . Se l e c t n e w g r a p h i c o b j e c t s . D e le t e e x is t in g g r a p h ic o b je c t s . Sa v e the curre nt gra p hic o bjects, th eir a tt r ib u te s , a n d th e g ra p h ic m o d e s .
H o w D C O p e ra te s ?
An a p plic ati o n ca n p erfor m the foll o w i n g o p e ra t io n s o n a d e v ic e c o n te x t : Re s t o r e p r e v i o u s l y s a v e d g r a p h i c o b j e c t s , t h e i r a tt r ib u te s , a n d th e g ra p h ic m o d e s . In a d diti o n, a n a p plic ati o n c a n u s e a d e vi c e c o n t e x t to : D e t e r m i n e h o w g r a p h i c s o u t p u t is t r a n s l a t e d . Ca n c e l l e n g t h y d r a w i n g o p e r a ti o n s ( b e g u n b y a t h r e a d in a m u l t i t h r e a d e d a p p l i c a t i o n ) . Re s e t a p r i n t e r t o a p a r t i c u l a r s t a t e .