00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
#include "magick/studio.h"
00043
#include "magick/annotate.h"
00044
#include "magick/blob.h"
00045
#include "magick/blob_private.h"
00046
#include "magick/draw.h"
00047
#include "magick/error.h"
00048
#include "magick/error_private.h"
00049
#include "magick/image.h"
00050
#include "magick/image_private.h"
00051
#include "magick/list.h"
00052
#include "magick/magick.h"
00053
#include "magick/memory_.h"
00054
#include "magick/static.h"
00055
#include "magick/string_.h"
00056
#include "magick/utility.h"
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 static Image *
ReadLABELImage(
const ImageInfo *image_info,
00087
ExceptionInfo *
exception)
00088 {
00089
char
00090 geometry[
MaxTextExtent];
00091
00092
DrawInfo
00093 *draw_info;
00094
00095
Image
00096 *image;
00097
00098
MagickBooleanType
00099 status;
00100
00101
TypeMetric
00102 metrics;
00103
00104
unsigned long
00105 height,
00106 width;
00107
00108
00109
00110
00111
assert(image_info != (
const ImageInfo *) NULL);
00112
assert(image_info->
signature ==
MagickSignature);
00113
if (image_info->
debug !=
MagickFalse)
00114 (
void)
LogMagickEvent(
TraceEvent,
GetMagickModule(),image_info->
filename);
00115
assert(exception != (
ExceptionInfo *) NULL);
00116
assert(exception->
signature ==
MagickSignature);
00117 image=
AllocateImage(image_info);
00118 draw_info=
CloneDrawInfo(image_info,(
DrawInfo *) NULL);
00119 draw_info->
fill=image_info->
pen;
00120 draw_info->
text=
TranslateText(image_info,image,image_info->
filename);
00121
if (draw_info->
text == (
char *) NULL)
00122
ThrowReaderException(
CoderError,
"UnableToTranslateText");
00123
if ((image->
columns != 0) || (image->
rows != 0))
00124 {
00125
00126
00127
00128 status=
GetTypeMetrics(image,draw_info,&metrics);
00129
for ( ; status !=
MagickFalse; draw_info->
pointsize*=2)
00130 {
00131 width=(
unsigned long) (metrics.
width+metrics.
max_advance/2+0.5);
00132 height=(
unsigned long) (metrics.
ascent-metrics.
descent+0.5);
00133
if (((image->
columns != 0) && (width >= image->
columns)) ||
00134 ((image->
rows != 0) && (height >= image->
rows)))
00135
break;
00136 status=
GetTypeMetrics(image,draw_info,&metrics);
00137 }
00138
for ( ; status !=
MagickFalse; draw_info->
pointsize--)
00139 {
00140 width=(
unsigned long) (metrics.
width+metrics.
max_advance/2+0.5);
00141 height=(
unsigned long) (metrics.
ascent-metrics.
descent+0.5);
00142
if ((image->
columns != 0) && (width <= image->
columns) &&
00143 ((image->
rows == 0) || (height <= image->
rows)))
00144
break;
00145
if ((image->
rows != 0) && (height <= image->
rows) &&
00146 ((image->
columns == 0) || (width <= image->
columns)))
00147
break;
00148
if (draw_info->
pointsize < 2.0)
00149
break;
00150 status=
GetTypeMetrics(image,draw_info,&metrics);
00151 }
00152 }
00153 status=
GetTypeMetrics(image,draw_info,&metrics);
00154
if (status ==
MagickFalse)
00155
ThrowReaderException(
TypeError,
"UnableToGetTypeMetrics");
00156 (
void)
FormatMagickString(geometry,
MaxTextExtent,
"+%g+%g",
00157 metrics.
max_advance/4,metrics.
ascent);
00158
if (image->
columns == 0)
00159 image->
columns=(
unsigned long) (metrics.
width+metrics.
max_advance/2+0.5);
00160
if (image->
rows == 0)
00161 {
00162 image->
rows=(
unsigned long) (metrics.
ascent-metrics.
descent+0.5);
00163 (
void)
FormatMagickString(geometry,
MaxTextExtent,
"+%g+%g",
00164 image->
columns/2.0-metrics.
width/2.0,metrics.
ascent);
00165 }
00166 draw_info->
geometry=
AcquireString(geometry);
00167
SetImage(image,
OpaqueOpacity);
00168 (
void)
AnnotateImage(image,draw_info);
00169 draw_info=
DestroyDrawInfo(draw_info);
00170
return(
GetFirstImageInList(image));
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 ModuleExport void RegisterLABELImage(
void)
00197 {
00198
MagickInfo
00199 *entry;
00200
00201 entry=
SetMagickInfo(
"LABEL");
00202 entry->
decoder=(
DecoderHandler *)
ReadLABELImage;
00203 entry->
adjoin=
MagickFalse;
00204 entry->
description=
AcquireString(
"Image label");
00205 entry->
module=
AcquireString(
"LABEL");
00206 (
void)
RegisterMagickInfo(entry);
00207 }
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 ModuleExport void UnregisterLABELImage(
void)
00229 {
00230 (
void)
UnregisterMagickInfo(
"LABEL");
00231 }