~ubuntu-branches/ubuntu/trusty/vips/trusty-proposed

« back to all changes in this revision

Viewing changes to libvips/create/point.c

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2014-03-29 12:29:29 UTC
  • mfrom: (1.1.21) (30.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20140329122929-fvxnaann32ex0gzk
Tags: 7.38.5-2
Enable dh-autoreconf. (Closes: #742872)

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
        VipsPoint *point = (VipsPoint *) a;
71
71
        VipsPointClass *class = VIPS_POINT_GET_CLASS( point ); 
72
72
        VipsRect *r = &or->valid;
73
 
        int le = r->left;
74
 
        int to = r->top;
75
 
        int ri = VIPS_RECT_RIGHT( r );
76
 
        int bo = VIPS_RECT_BOTTOM( r );
77
73
 
78
74
        int x, y;
79
75
 
80
 
        for( y = to; y < bo; y++ ) {
81
 
                float *q = (float *) VIPS_REGION_ADDR( or, le, y );
 
76
        for( y = 0; y < r->height; y++ ) {
 
77
                int ay = r->top + y;
 
78
                float *q = (float *) VIPS_REGION_ADDR( or, r->left, ay ); 
82
79
 
83
 
                for( x = le; x < ri; x++ ) 
84
 
                        *q++ = class->point( point, x, y ); 
 
80
                for( x = 0; x < r->width; x++ ) 
 
81
                        q[x] = class->point( point, r->left + x, ay ); 
85
82
        }
86
83
 
87
84
        return( 0 );
91
88
vips_point_build( VipsObject *object )
92
89
{
93
90
        VipsCreate *create = VIPS_CREATE( object );
94
 
        VipsPoint *point = (VipsPoint *) object;
95
 
        VipsImage **t = (VipsImage **) vips_object_local_array( object, 3 );
 
91
        VipsPoint *point = VIPS_POINT( object );
 
92
        VipsPointClass *class = VIPS_POINT_GET_CLASS( point );
 
93
        VipsImage **t = (VipsImage **) vips_object_local_array( object, 4 );
 
94
 
96
95
        VipsImage *in;
97
96
 
98
97
        if( VIPS_OBJECT_CLASS( vips_point_parent_class )->build( object ) )
101
100
        t[0] = vips_image_new();
102
101
        vips_image_init_fields( t[0],
103
102
                point->width, point->height, 1,
104
 
                VIPS_FORMAT_FLOAT, VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W,
 
103
                VIPS_FORMAT_FLOAT, VIPS_CODING_NONE, class->interpretation,
105
104
                1.0, 1.0 );
106
 
        vips_demand_hint( t[0], 
 
105
        vips_image_pipelinev( t[0], 
107
106
                VIPS_DEMAND_STYLE_ANY, NULL );
108
107
        if( vips_image_generate( t[0], 
109
108
                NULL, vips_point_gen, NULL, point, NULL ) )
110
109
                return( -1 );
111
 
 
112
110
        in = t[0];
 
111
 
113
112
        if( point->uchar ) {
114
 
                if( vips_linear1( in, &t[1], 127.5, 127.5, NULL ) ||
115
 
                        vips_cast( t[1], &t[2], VIPS_FORMAT_UCHAR, NULL ) )
 
113
                float min = class->min;
 
114
                float max = class->max;
 
115
                float range = max - min;
 
116
 
 
117
                if( vips_linear1( in, &t[2], 
 
118
                        255.0 / range, -min * 255.0 / range, 
 
119
                        "uchar", TRUE,
 
120
                        NULL ) )
116
121
                        return( -1 );
117
122
                in = t[2];
 
123
 
 
124
                /* uchar mode always does B_W. We don't want FOURIER or
 
125
                 * whatever in this case.
 
126
                 */
 
127
                in->Type = VIPS_INTERPRETATION_B_W;
118
128
        }
119
129
 
120
130
        if( vips_image_write( in, create->out ) )
136
146
        vobject_class->description = _( "make a point image" );
137
147
        vobject_class->build = vips_point_build;
138
148
 
 
149
        class->point = NULL; 
 
150
        class->min = -1.0; 
 
151
        class->max = 1.0; 
 
152
        class->interpretation = VIPS_INTERPRETATION_B_W;
 
153
 
139
154
        VIPS_ARG_INT( class, "width", 2, 
140
155
                _( "Width" ), 
141
156
                _( "Image width in pixels" ),
150
165
                G_STRUCT_OFFSET( VipsPoint, height ),
151
166
                1, 1000000, 1 );
152
167
 
153
 
        VIPS_ARG_BOOL( class, "uchar", 7, 
 
168
        VIPS_ARG_BOOL( class, "uchar", 4, 
154
169
                _( "Uchar" ), 
155
170
                _( "Output an unsigned char image" ),
156
171
                VIPS_ARGUMENT_OPTIONAL_INPUT,