~ubuntu-branches/ubuntu/quantal/imagemagick/quantal

« back to all changes in this revision

Viewing changes to magick/quantum-private.h

  • Committer: Bazaar Package Importer
  • Author(s): Muharem Hrnjadovic
  • Date: 2009-06-04 13:01:13 UTC
  • mfrom: (1.1.5 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090604130113-my9114jxmafpwew3
Tags: 7:6.5.1.0-1.1ubuntu1
* Merge from debian unstable, remaining changes:
  - (Build-)depend on libltdl7-dev instead of libltdl3-dev (the armel buildds
    currently have both available).
  - Don't build-dep on librsvg, it brings in excessive dependencies

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
extern "C" {
23
23
#endif
24
24
 
 
25
#include "magick/cache.h"
 
26
 
25
27
typedef struct _QuantumState
26
28
{
27
29
  EndianType
64
66
  QuantumAlphaType
65
67
    alpha_type;
66
68
 
 
69
  unsigned long
 
70
    number_threads;
 
71
 
67
72
  unsigned char
68
 
    *pixels;
 
73
    **pixels;
69
74
 
70
75
  size_t
71
76
    extent;
83
88
    ((MagickULLConstant(1) << (depth-1))-1)));
84
89
}
85
90
 
86
 
static inline QuantumAny GetQuantumScale(const unsigned long depth)
87
 
{
88
 
  if ((depth == 0) || (depth == MAGICKCORE_QUANTUM_DEPTH))
89
 
    return(1);
90
 
  if (depth < MAGICKCORE_QUANTUM_DEPTH)
91
 
    return((QuantumAny) (QuantumRange/((MagickSizeType) QuantumRange >>
92
 
      (MAGICKCORE_QUANTUM_DEPTH-depth))));
93
 
  return((QuantumAny) ((MagickSizeType) ((MagickULLConstant(1) << (depth-1))+
94
 
    ((MagickULLConstant(1) << (depth-1))-1))/QuantumRange));
95
 
}
96
 
 
97
91
static inline void InitializeQuantumState(const QuantumInfo *quantum_info,
98
92
  const EndianType endian,QuantumState *quantum_state)
99
93
{
218
212
}
219
213
 
220
214
static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
221
 
  const unsigned long depth,const QuantumAny scale)
 
215
  const QuantumAny range)
222
216
{
223
 
  if (depth == MAGICKCORE_QUANTUM_DEPTH)
224
 
    return((Quantum) quantum);
225
 
  if (depth > MAGICKCORE_QUANTUM_DEPTH)
226
 
    return((Quantum) (quantum/scale));
227
 
  return((Quantum) (scale*quantum));
 
217
  return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
228
218
}
229
219
 
230
220
static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
231
 
  const unsigned long depth,const QuantumAny scale)
 
221
  const QuantumAny range)
232
222
{
233
 
  if (depth == MAGICKCORE_QUANTUM_DEPTH)
234
 
    return((QuantumAny) quantum);
235
 
  if (depth < MAGICKCORE_QUANTUM_DEPTH)
236
 
    return((QuantumAny) (quantum/scale));
237
 
  return((QuantumAny) (scale*quantum));
 
223
  return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
238
224
}
239
225
 
240
226
#if (MAGICKCORE_QUANTUM_DEPTH == 8)
280
266
 
281
267
static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
282
268
{
283
 
  if (quantum <= 0)
284
 
    return(0UL);
285
269
  if (quantum >= (Quantum) MaxMap)
286
270
    return((unsigned long) MaxMap);
287
271
#if !defined(MAGICKCORE_HDRI_SUPPORT)
288
272
  return((unsigned long) quantum);
289
273
#else
 
274
  if (quantum < 0.0)
 
275
    return(0UL);
290
276
  return((unsigned long) (quantum+0.5));
291
277
#endif
292
278
}
360
346
 
361
347
static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
362
348
{
363
 
  if (quantum <= 0)
364
 
    return(0);
365
349
  if (quantum >= (Quantum) MaxMap)
366
350
    return((unsigned long) MaxMap);
367
351
#if !defined(MAGICKCORE_HDRI_SUPPORT)
368
352
  return((unsigned long) quantum);
369
353
#else
 
354
  if (quantum < 0.0)
 
355
    return(0UL);
370
356
  return((unsigned long) (quantum+0.5));
371
357
#endif
372
358
}
423
409
 
424
410
static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
425
411
{
426
 
  if (quantum <= 0.0)
427
 
    return(0);
428
 
  if ((quantum/65537.0) >= MaxMap)
 
412
  if ((quantum/65537) >= MaxMap)
429
413
    return((unsigned long) MaxMap);
430
414
#if !defined(MAGICKCORE_HDRI_SUPPORT)
431
415
  return((unsigned long) ((quantum+MagickULLConstant(32768))/
432
416
    MagickULLConstant(65537)));
433
417
#else
 
418
  if (quantum < 0.0)
 
419
    return(0UL);
434
420
  return((unsigned long) (quantum/65537.0)+0.5);
435
421
#endif
436
422
}
500
486
 
501
487
static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
502
488
{
503
 
  if (quantum <= 0.0)
504
 
    return(0);
505
489
  if ((quantum/281479271612415.0) >= MaxMap)
506
490
    return((unsigned long) MaxMap);
507
491
#if !defined(MAGICKCORE_HDRI_SUPPORT)
508
492
  return((unsigned long) ((quantum+2147450879.0)/281479271612415.0));
509
493
#else
 
494
  if (quantum < 0.0)
 
495
    return(0UL);
510
496
  return((unsigned long) (quantum/281479271612415.0)+0.5);
511
497
#endif
512
498
}