Skip to content

Commit

Permalink
Support the authenticate, orientation, pointsize, and sampling_factor…
Browse files Browse the repository at this point in the history
… attribute accessors in the Image::Info class.
  • Loading branch information
rmagick committed Jun 10, 2005
1 parent 5433f9f commit c6cc496
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 5 deletions.
5 changes: 4 additions & 1 deletion ext/RMagick/rmagick.h
@@ -1,4 +1,4 @@
/* $Id: rmagick.h,v 1.84 2005/06/09 23:17:54 rmagick Exp $ */
/* $Id: rmagick.h,v 1.85 2005/06/10 22:41:19 rmagick Exp $ */
/*=============================================================================
| Copyright (C) 2005 by Timothy P. Hunter
| Name: rmagick.h
Expand Down Expand Up @@ -551,6 +551,7 @@ extern void rm_imagelist_push(VALUE, VALUE);

// rminfo.c
ATTR_ACCESSOR(Info, antialias)
ATTR_ACCESSOR(Info, authenticate)
ATTR_ACCESSOR(Info, background_color)
ATTR_ACCESSOR(Info, border_color)
ATTR_ACCESSOR(Info, colorspace)
Expand All @@ -569,11 +570,13 @@ ATTR_ACCESSOR(Info, interlace)
ATTR_ACCESSOR(Info, matte_color)
ATTR_ACCESSOR(Info, monochrome)
ATTR_ACCESSOR(Info, number_scenes)
ATTR_ACCESSOR(Info, orientation)
ATTR_ACCESSOR(Info, page)
ATTR_ACCESSOR(Info, pen)
// ATTR_ACCESSOR(Info, ping) obsolete
ATTR_ACCESSOR(Info, pointsize)
ATTR_ACCESSOR(Info, quality)
ATTR_ACCESSOR(Info, sampling_factor)
ATTR_ACCESSOR(Info, scene)
ATTR_ACCESSOR(Info, server_name)
ATTR_ACCESSOR(Info, subimage)
Expand Down
136 changes: 134 additions & 2 deletions ext/RMagick/rminfo.c
@@ -1,4 +1,4 @@
/* $Id: rminfo.c,v 1.29 2005/06/09 23:17:54 rmagick Exp $ */
/* $Id: rminfo.c,v 1.30 2005/06/10 22:41:19 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2005 by Timothy P. Hunter
| Name: rminfo.c
Expand Down Expand Up @@ -152,6 +152,51 @@ Info_aset(VALUE self, VALUE format, VALUE key, VALUE value)
}


VALUE
Info_authenticate(VALUE self)
{
Info *info;

Data_Get_Struct(self, Info, info);
if (info->authenticate)
{
return rb_str_new2(info->authenticate);
}
else
{
return Qnil;
}
}


VALUE
Info_authenticate_eq(VALUE self, VALUE passwd)
{
Info *info;
char *passwd_p;
long passwd_len = 0;

Data_Get_Struct(self, Info, info);

if (!NIL_P(passwd))
{
passwd_p = STRING_PTR_LEN(passwd, passwd_len);
}

if (info->authenticate)
{
magick_free(info->authenticate);
info->authenticate = NULL;
}
if (passwd_len > 0)
{
magick_clone_string(&info->authenticate, passwd_p);
}

return self;
}


/*
Method: Info#background_color
Purpose: return the name of the background color as a String
Expand Down Expand Up @@ -811,6 +856,45 @@ Info_number_scenes_eq(VALUE self, VALUE nscenes)
}
#endif

/*
Method: Info#orientation
Purpose: Return the orientation attribute as an OrientationType enum value.
*/
VALUE
Info_orientation(VALUE self)
{
#if defined(HAVE_IMAGE_ORIENTATION)
Info *info;

Data_Get_Struct(self, Info, info);
return OrientationType_new(info->orientation);
#else
rm_not_implemented();
return (VALUE)0;
#endif
}


/*
Method: Info#Orientation=
Purpose: Set the Orientation type
Raises: ArgumentError
*/
VALUE
Info_orientation_eq(VALUE self, VALUE inter)
{
#if defined(HAVE_IMAGE_ORIENTATION)
Info *info;

Data_Get_Struct(self, Info, info);
VALUE_TO_ENUM(inter, info->orientation, OrientationType);
return self;
#else
rm_not_implemented();
return (VALUE)0;
#endif
}

DEF_ATTR_READER(Info, page, str)

/*
Expand Down Expand Up @@ -844,9 +928,57 @@ Info_page_eq(VALUE self, VALUE page_arg)
return self;
}

DEF_ATTR_ACCESSOR(Info, pointsize, dbl)
DEF_ATTR_ACCESSOR(Info, pointsize, dbl)
DEF_ATTR_ACCESSOR(Info, quality, long)

/*
Method: Info#sampling_factor, #sampling_factor=
Purpose: get/set sampling factors used by JPEG or MPEG-2 encoder
and YUV decoder/encoder
*/
VALUE
Info_sampling_factor(VALUE self)
{
Info *info;

Data_Get_Struct(self, Info, info);
if (info->sampling_factor)
{
return rb_str_new2(info->sampling_factor);
}
else
{
return Qnil;
}
}

VALUE
Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
{
Info *info;
char *sampling_factor_p;
long sampling_factor_len = 0;

Data_Get_Struct(self, Info, info);

if (!NIL_P(sampling_factor))
{
sampling_factor_p = STRING_PTR_LEN(sampling_factor, sampling_factor_len);
}

if (info->sampling_factor)
{
magick_free(info->sampling_factor);
info->sampling_factor = NULL;
}
if (sampling_factor_len > 0)
{
magick_clone_string(&info->sampling_factor, sampling_factor_p);
}

return self;
}

#ifdef HAVE_IMAGEINFO_NUMBER_SCENES

// Info#scene, scene= is the IM >= 5.5.6 version of the now-deprecated
Expand Down
7 changes: 5 additions & 2 deletions ext/RMagick/rmmain.c
@@ -1,4 +1,4 @@
/* $Id: rmmain.c,v 1.86 2005/06/09 23:17:54 rmagick Exp $ */
/* $Id: rmmain.c,v 1.87 2005/06/10 22:41:19 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2005 by Timothy P. Hunter
| Name: rmmain.c
Expand Down Expand Up @@ -933,6 +933,7 @@ Init_RMagick(void)
rb_define_method(Class_Info, "undefine", Info_undefine, 2);

DCL_ATTR_ACCESSOR(Info, antialias)
DCL_ATTR_ACCESSOR(Info, authenticate)
DCL_ATTR_ACCESSOR(Info, background_color)
DCL_ATTR_ACCESSOR(Info, border_color)
DCL_ATTR_ACCESSOR(Info, colorspace)
Expand All @@ -950,9 +951,11 @@ Init_RMagick(void)
DCL_ATTR_ACCESSOR(Info, matte_color)
DCL_ATTR_ACCESSOR(Info, monochrome)
DCL_ATTR_ACCESSOR(Info, number_scenes) // new in 5.5.6, replaces subrange
DCL_ATTR_ACCESSOR(Info, orientation) // new in 6.0.0
DCL_ATTR_ACCESSOR(Info, page)
DCL_ATTR_ACCESSOR(Info, pointsize)
DCL_ATTR_ACCESSOR(Info, quality)
DCL_ATTR_ACCESSOR(Info, sampling_factor)
DCL_ATTR_ACCESSOR(Info, scene) // new in 5.5.6, replaces subimage
DCL_ATTR_ACCESSOR(Info, server_name)
DCL_ATTR_ACCESSOR(Info, size)
Expand Down Expand Up @@ -1515,7 +1518,7 @@ static void version_constants(void)

rb_define_const(Module_Magick, "Version", rb_str_new2(PACKAGE_STRING));
sprintf(long_version,
"This is %s ($Date: 2005/06/09 23:17:54 $) Copyright (C) 2005 by Timothy P. Hunter\n"
"This is %s ($Date: 2005/06/10 22:41:19 $) Copyright (C) 2005 by Timothy P. Hunter\n"
"Built with %s\n"
"Built for %s\n"
"Web page: http://rmagick.rubyforge.org\n"
Expand Down

0 comments on commit c6cc496

Please sign in to comment.