mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Merge pull request #102 from cgohlke/patch-1
Make _webp.c compatible with msvc
This commit is contained in:
		
						commit
						50878f5767
					
				
							
								
								
									
										24
									
								
								_webp.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								_webp.c
									
									
									
									
									
								
							| 
						 | 
					@ -9,14 +9,16 @@ PyObject* WebPEncodeRGB_wrapper(PyObject* self, PyObject* args)
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int stride;
 | 
					    int stride;
 | 
				
			||||||
    float quality_factor;
 | 
					    float quality_factor;
 | 
				
			||||||
 | 
					    uint8_t *rgb;
 | 
				
			||||||
 | 
					    uint8_t *output;
 | 
				
			||||||
 | 
					    Py_ssize_t size;
 | 
				
			||||||
 | 
					    size_t ret_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!PyArg_ParseTuple(args, "Siiif", &rgb_string, &width, &height, &stride, &quality_factor)) {
 | 
					    if (!PyArg_ParseTuple(args, "Siiif", &rgb_string, &width, &height, &stride, &quality_factor)) {
 | 
				
			||||||
        Py_INCREF(Py_None);
 | 
					        Py_INCREF(Py_None);
 | 
				
			||||||
        return Py_None;
 | 
					        return Py_None;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    uint8_t *rgb;
 | 
					 | 
				
			||||||
    Py_ssize_t size;
 | 
					 | 
				
			||||||
    PyString_AsStringAndSize((struct PyObject *) rgb_string, &rgb, &size);
 | 
					    PyString_AsStringAndSize((struct PyObject *) rgb_string, &rgb, &size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (stride * height > size) {
 | 
					    if (stride * height > size) {
 | 
				
			||||||
| 
						 | 
					@ -24,8 +26,7 @@ PyObject* WebPEncodeRGB_wrapper(PyObject* self, PyObject* args)
 | 
				
			||||||
        return Py_None;
 | 
					        return Py_None;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    uint8_t *output;
 | 
					    ret_size = WebPEncodeRGB(rgb, width, height, stride, quality_factor, &output);
 | 
				
			||||||
    size_t ret_size = WebPEncodeRGB(rgb, width, height, stride, quality_factor, &output);
 | 
					 | 
				
			||||||
    if (ret_size > 0) {
 | 
					    if (ret_size > 0) {
 | 
				
			||||||
        PyObject *ret = PyString_FromStringAndSize(output, ret_size);
 | 
					        PyObject *ret = PyString_FromStringAndSize(output, ret_size);
 | 
				
			||||||
        free(output);
 | 
					        free(output);
 | 
				
			||||||
| 
						 | 
					@ -40,20 +41,23 @@ PyObject* WebPDecodeRGB_wrapper(PyObject* self, PyObject* args)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    PyStringObject *webp_string;
 | 
					    PyStringObject *webp_string;
 | 
				
			||||||
    float quality_factor;
 | 
					    float quality_factor;
 | 
				
			||||||
 | 
					    int width;
 | 
				
			||||||
 | 
					    int height;
 | 
				
			||||||
 | 
					    uint8_t *webp;
 | 
				
			||||||
 | 
					    uint8_t *output;
 | 
				
			||||||
 | 
					    Py_ssize_t size;
 | 
				
			||||||
 | 
					    PyObject *ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!PyArg_ParseTuple(args, "S", &webp_string)) {
 | 
					    if (!PyArg_ParseTuple(args, "S", &webp_string)) {
 | 
				
			||||||
        Py_INCREF(Py_None);
 | 
					        Py_INCREF(Py_None);
 | 
				
			||||||
        return Py_None;
 | 
					        return Py_None;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    uint8_t *webp;
 | 
					
 | 
				
			||||||
    Py_ssize_t size;
 | 
					 | 
				
			||||||
    PyString_AsStringAndSize((struct PyObject *) webp_string, &webp, &size);
 | 
					    PyString_AsStringAndSize((struct PyObject *) webp_string, &webp, &size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int width;
 | 
					    output = WebPDecodeRGB(webp, size, &width, &height);
 | 
				
			||||||
    int height;
 | 
					 | 
				
			||||||
    uint8_t *output = WebPDecodeRGB(webp, size, &width, &height);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PyObject *ret = PyString_FromStringAndSize(output, width * height * 3);
 | 
					    ret = PyString_FromStringAndSize(output, width * height * 3);
 | 
				
			||||||
    free(output);
 | 
					    free(output);
 | 
				
			||||||
    return Py_BuildValue("Sii", ret, width, height);
 | 
					    return Py_BuildValue("Sii", ret, width, height);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user