MHEG5  18.9.0
MHEG5 Documentation
mh5bitmap.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
31 /*---includes for this file--------------------------------------------------*/
32 #include "mh5application.h" /* Application class header file. */
33 #include "mh5bitmap.h" /* Bitmap class header file. */
34 #include "mh5object.h" /* For actions. */
35 #include "mh5variable.h" /* For actions. */
36 #include "mh5display.h" /* For actions. */
37 #include "mh5memory.h" /* For constructor/destructor. */
38 #include "mh5debug.h" /* Debug header file. */
39 #include "mh5misc.h"
40 #include "mh5profile.h"
41 #include "mg_api.h"
42 
43 #ifdef MH5PRINTOUT /* Check if MHEG5 printout is required. */
44 #include <string.h> /* String mani[ulation functions. */
45 #endif
46 
47 /*---constant definitions for this file--------------------------------------*/
48 
49 
50 /*---local typedef structs for this file-------------------------------------*/
51 
52 /*---local (static) variable declarations for this file----------------------*/
53 
54 /*---local function definitions----------------------------------------------*/
55 
56 /*---global function definitions---------------------------------------------*/
57 
58 
59 #ifdef MH5PRINTOUT
60 
66 void MHEG5bitmapPrint(MHEG5Bitmap *bitmap, char *out)
67 {
68  /* Inherited class */
69  MHEG5visiblePrint(&bitmap->visible, out);
70 
71  /* Exchanged attributes */
72  if (bitmap->tiling)
73  {
74  MHEG5indent(out);
75  MHEG_PRINT(out, ":Tiling TRUE");
76  MHEG5newLine(out);
77  }
78 
79  if (bitmap->originalTransparency != 0)
80  {
81  MHEG5indent(out);
82  MHEG_PRINT(out, ":originalTransparency ");
83  MHEG5intPrint(bitmap->originalTransparency, out);
84  MHEG5newLine(out);
85  }
86 }
87 
88 #endif
89 
96 {
97  assert(bitmap);
98 
99  MHEG5visibleInit(&bitmap->visible);
100 }
101 
110 {
111  assert(bitmap);
112 
113  MHEG5visibleFree(&bitmap->visible);
114 }
115 
122 {
123  MHEG5Bitmap *destination;
124 
125  assert(source);
126  destination = (MHEG5Bitmap *)MHEG5getMem( sizeof(MHEG5Bitmap));
127  if (destination != NULL)
128  {
129  memset( destination, 0, sizeof(MHEG5Bitmap));
130  destination->visible.ingredient.root.clazz = MHEG5BITMAP;
131 
132  MHEG5visibleClone(&destination->visible, &source->visible);
133  destination->tiling = source->tiling;
134  destination->originalTransparency = source->originalTransparency;
135  }
136  return destination;
137 }
138 
147 {
148  assert(bitmap);
149  bitmap->transparency = bitmap->originalTransparency;
150  bitmap->xOffset = 0;
151  bitmap->yOffset = 0;
152  bitmap->scaleSet = MHEG5FALSE;
153 
154  MHEG5visiblePrepare(&bitmap->visible);
155 }
156 
165 {
166  assert(bitmap);
167 
168  if (!bitmap->visible.ingredient.root.runningStatus)
169  {
171  {
172  MHEG5bitmapPrepare( bitmap );
173  }
175  {
177  if (cp)
178  {
180  }
181  }
182  /* Check whether this is an I-frame */
185  #ifdef INCLUDE_FREESAT
186  || bitmap->visible.ingredient.contentHook == CHOOK_BITMAP_IMAGE_PLANE_IFRAME
187  #endif
188  )
189  {
190  /* Check that we have something to show */
191  if ((bitmap->visible.ingredient.data != NULL) &&
192  (bitmap->visible.ingredient.dataLen > 0))
193  {
194  /* Start displaying I-Frame */
195  MHEG5displayIFrameStart( bitmap );
196  }
197  }
198 
199  MHEG5visibleActivate(&bitmap->visible);
200  }
201 }
202 
211 {
212  assert(bitmap);
213 
214  if (bitmap->visible.ingredient.root.runningStatus)
215  {
216  switch (bitmap->visible.ingredient.contentHook)
217  {
218  case CHOOK_BITMAP_PNG:
219  case CHOOK_BITMAP_JPG:
220  if (bitmap->visible.graphic_data != NULL)
221  {
222  MG_FreeData( bitmap->visible.graphic_data );
223  bitmap->visible.graphic_data = NULL;
224  }
225  break;
226 
229  /* If this is an I-frame bitmap, reset the scaling of the video decoder */
231  break;
232 
233  #ifdef INCLUDE_FREESAT
234  case CHOOK_BITMAP_IMAGE_PLANE_IFRAME:
235  MHEG5displayImagePlaneStop();
236  break;
237  #endif
238 
239  default:;
240  }
242  }
243 }
244 
251 {
252  assert(bitmap);
253  MHEG5visibleDestruct(&bitmap->visible);
256  #ifdef INCLUDE_FREESAT
257  || bitmap->visible.ingredient.contentHook == CHOOK_BITMAP_IMAGE_PLANE_IFRAME
258  #endif
259  )
260  {
261  MHEG5displayIframeDestroy( bitmap );
262  }
263 }
264 
265 /* Bitmap Actions. */
266 
277 {
278  MHEG5GList *thirdParam;
279  MHEG5Int x = 0, y = 0;
280 
281  assert(target);
282 
283  if (target->clazz != MHEG5BITMAP)
284  {
285  return MHEG5ERR_WRONGTARGET;
286  }
287  if (!params)
288  {
290  }
291 
292  thirdParam = MHEG5resolveGenericInteger(params, &x);
293  if (!thirdParam)
294  {
296  }
297 
298  MHEG5resolveGenericInteger(thirdParam, &y);
299 
300  if ((x > 0) && (y > 0))
301  {
302  ((MHEG5Bitmap *)target)->scaleSet = MHEG5TRUE;
303  ((MHEG5Bitmap *)target)->xscale = x;
304  ((MHEG5Bitmap *)target)->yscale = y;
305 
306  if (target->runningStatus)
307  {
308  if (((MHEG5Ingredient *)target)->contentHook == CHOOK_BITMAP_NORMAL_IFRAME ||
309  ((MHEG5Ingredient *)target)->contentHook == CHOOK_BITMAP_H264_IFRAME
310  )
311  {
313  }
314  }
315  }
316  return MHEG5ERR_NOERROR;
317 }
318 
328 {
329  MHEG5Int tr = -1;
330 
331  if (target->clazz != MHEG5BITMAP)
332  {
333  return MHEG5ERR_WRONGTARGET;
334  }
335 
336  if (!params)
337  {
339  }
340  MHEG5resolveGenericInteger(params, &tr);
341 
342  if ((tr >= 0) && (tr <= 100))
343  {
344  ((MHEG5Bitmap *) target)->transparency = tr;
345  MHEG5displayRedraw((MHEG5Visible *) target);
346  }
347  return MHEG5ERR_NOERROR;
348 }
349 
377 {
378  MHEG5GList *thirdParam = 0;
379  MHEG5Bitmap *bitmap = 0;
380  MHEG5Int xOffset = 0, yOffset = 0;
381 
382  assert(target);
383 
384  if (target->clazz != MHEG5BITMAP)
385  {
386  return MHEG5ERR_WRONGTARGET;
387  }
388 
389  if (!params)
390  {
392  }
393  thirdParam = MHEG5resolveGenericInteger(params, &xOffset);
394 
395  if (!thirdParam)
396  {
398  }
399  MHEG5resolveGenericInteger(thirdParam, &yOffset);
400 
401  bitmap = (MHEG5Bitmap *)target;
402  bitmap->xOffset = xOffset;
403  bitmap->yOffset = yOffset;
404  if (bitmap->visible.ingredient.root.runningStatus)
405  {
407  }
408 
409  return MHEG5ERR_NOERROR;
410 }
411 
433 {
434  MHEG5GList *thirdParam = 0;
435  MHEG5Root *xOffset, *yOffset;
436  MHEG5Bitmap *bitmap;
437 
438  assert(target);
439 
440  if (target->clazz != MHEG5BITMAP)
441  {
442  return MHEG5ERR_WRONGTARGET;
443  }
444  bitmap = (MHEG5Bitmap *)target;
445 
446  if (!params)
447  {
449  }
450  thirdParam = MHEG5resolveORef(params, &xOffset);
451 
452  if (!thirdParam)
453  {
455  }
456  MHEG5resolveORef(thirdParam, &yOffset);
457 
458  if (!xOffset || !yOffset)
459  {
461  }
462  if (xOffset->clazz != MHEG5INTEGERVARIABLE ||
463  yOffset->clazz != MHEG5INTEGERVARIABLE)
464  {
465  return MHEG5ERR_WRONGPARAM;
466  }
467  if (!xOffset->runningStatus || !yOffset->runningStatus)
468  {
470  }
471 
472  ((MHEG5IntegerVariable *) xOffset)->value = bitmap->xOffset;
473  ((MHEG5IntegerVariable *) yOffset)->value = bitmap->yOffset;
474 
475  return MHEG5ERR_NOERROR;
476 }
477 
MHEG5Bool availabilityStatus
Definition: mh5root.h:52
MHEG5Int originalTransparency
Definition: mh5bitmap.h:60
MHEG5Byte * data
Definition: mh5ingredient.h:80
void MHEG5visibleActivate(MHEG5Visible *visible)
Apply the activation behaviour of the visible class. Apply the activation behaviour off the visible c...
Definition: mh5visible.c:306
MHEG5ErrorCode MHEG5setTransparency(MHEG5Root *target, MHEG5GList *params)
Change the value of the Transparency attribute. Implementation of the SetTransparency (NewTransparenc...
Definition: mh5bitmap.c:327
MHEG5ErrorCode MHEG5getBitmapDecodeOffset(MHEG5Root *target, MHEG5GList *params)
Implementation of the GetBitmapDecodeOffset (XOffset, YOffset) action of the bitmap class GetBitmapDe...
Definition: mh5bitmap.c:432
MHEG5GList * MHEG5resolveGenericInteger(MHEG5GList *params, MHEG5Int *value)
Definition: mh5object.c:510
#define CHOOK_BITMAP_NORMAL_IFRAME
Definition: mh5profile.h:94
#define MHEG5getMem
Definition: glue_memory.h:93
MHEG5Final clazz
Definition: mh5root.h:55
void MHEG5visibleFree(MHEG5Visible *visible)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5visible.c:186
void MG_FreeData(void *data)
free surface buffer
Definition: mg_osd.c:1536
Miscellaneous.
MHEG5Bool tiling
Definition: mh5bitmap.h:59
void MHEG5visiblePrepare(MHEG5Visible *visible)
Apply the preparation behaviour off the visible class Apply the preparation behaviour of the visible ...
Definition: mh5visible.c:239
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5displayVideoPositionUpdate(void)
Definition: mh5display.c:2729
void * graphic_data
Definition: mh5visible.h:64
void MHEG5visibleDestruct(MHEG5Visible *visible)
Destruct a visible object.
Definition: mh5visible.c:282
#define CHOOK_BITMAP_JPG
Definition: mh5profile.h:99
long MHEG5Int
Definition: mh5base.h:73
#define CHOOK_BITMAP_H264_IFRAME
Definition: mh5profile.h:100
MHEG5ErrorCode MHEG5scaleBitmap(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to scale the contents of the Bitmap to the size (XScale, YScale). Implementation of the ScaleBitmap (XScale, YScale) action of the bitmap class.
Definition: mh5bitmap.c:276
This file defines the profile for the MHEG engine.
void MHEG5bitmapPrepare(MHEG5Bitmap *bitmap)
Apply the preparation behaviour of the bitmap class. As this class has no own preparation behaviour t...
Definition: mh5bitmap.c:146
#define MHEG5displayRedraw(v)
Definition: mh5display.h:47
MHEG5ErrorCode
Definition: mh5base.h:222
void MHEG5displayIFrameStart(MHEG5Bitmap *bitmap)
Start displaying an I-Frame.
Definition: mh5display.c:2614
void MHEG5bitmapDeactivate(MHEG5Bitmap *bitmap)
Apply the deactivation behaviour of the bitmap class. As this class has no own deactivation behaviour...
Definition: mh5bitmap.c:210
MHEG5Int yOffset
Definition: mh5bitmap.h:54
Module Description: Implement the MHEG5 Bitmap Class. 32 Bitmap Class Defines the behaviour of a two-...
MHEG5Int transparency
Definition: mh5bitmap.h:57
#define MHEG5TRUE
Definition: mh5base.h:49
MHEG5Int bitmapContentHook
MHEG5ErrorCode MHEG5setBitmapDecodeOffset(MHEG5Root *target, MHEG5GList *params)
Implementation of the SetBitmapDecodeOffset (NewXOffset, NewYOffset) action of the bitmap class...
Definition: mh5bitmap.c:376
MHEG5Bool scaleSet
Definition: mh5bitmap.h:48
void MHEG5bitmapDestruct(MHEG5Bitmap *bitmap)
Destruct a bitmap object.
Definition: mh5bitmap.c:250
Implement functions to retrieve MHEG5objects by GroupID and ID.
Implementation of the MHEG5 Application Class Defines a set of Ingredient objects, which are shared within an application scope. Base class: Group Subclasses: None Status: Concrete class.
Mheg5 logging and debug printing.
MHEG5Bool runningStatus
Definition: mh5root.h:51
MHEG5Ingredient ingredient
Definition: mh5visible.h:49
redirection include
MHEG5Bitmap * MHEG5bitmapClone(MHEG5Bitmap *source)
Copy a bitmap object with original values.
Definition: mh5bitmap.c:121
void MHEG5visibleClone(MHEG5Visible *destination, MHEG5Visible *source)
Copy a visible object with original values.
Definition: mh5visible.c:206
MHEG5Int xOffset
Definition: mh5bitmap.h:53
void MHEG5bitmapFree(MHEG5Bitmap *bitmap)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5bitmap.c:109
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
void MHEG5visibleDeactivate(MHEG5Visible *visible)
Apply the deactivation behaviour of the visible class. As this class has no own deactivation behaviou...
Definition: mh5visible.c:338
#define MHEG5CHOOK_UNDEFINED
Definition: mh5ingredient.h:35
void MHEG5bitmapActivate(MHEG5Bitmap *bitmap)
Apply the activation behaviour of the bitmap class. As this class has no own activation behaviour thi...
Definition: mh5bitmap.c:164
#define CHOOK_BITMAP_PNG
Definition: mh5profile.h:95
MHEG5Int contentHook
Definition: mh5ingredient.h:69
void MHEG5displayIframeDestroy(MHEG5Bitmap *iframe)
Definition: mh5display.c:2600
#define MHEG5FALSE
Definition: mh5base.h:48
void MHEG5displayIFrameStop(void)
Stop displaying an I-Frame.
Definition: mh5display.c:2717
void MHEG5bitmapInit(MHEG5Bitmap *bitmap)
Initialise a bitmap object with default values.
Definition: mh5bitmap.c:95
MHEG5Visible visible
Definition: mh5bitmap.h:45
void MHEG5visibleInit(MHEG5Visible *visible)
Initialise a visible object with default values.
Definition: mh5visible.c:172
MHEG5Application * MHEG5getCurrentApplication(void)
<Function description>="">