From: Editor Lionbridge Date: Tue, 23 May 2017 08:04:53 +0000 (+0300) Subject: Change image editing guide X-Git-Tag: GitHub/PR#40/tizen-studio~145^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F51%2F130651%2F1;p=sdk%2Fonline-doc.git Change image editing guide This is a manual cherry-pick from the #126852 change in the tizen_3.0 branch. Change-Id: Ie270e2f564ecc3be662ec5a408f9cae3f90085a0 --- diff --git a/org.tizen.guides/html/native/media/image_edit_n.htm b/org.tizen.guides/html/native/media/image_edit_n.htm index 8b3c88d..49e541e 100644 --- a/org.tizen.guides/html/native/media/image_edit_n.htm +++ b/org.tizen.guides/html/native/media/image_edit_n.htm @@ -38,7 +38,8 @@
  • Decoding from a File or Memory
  • Encoding to a File or Memory
  • -
  • Supported Colorspace Formats
  • +
  • Encoding an Animated GIF
  • +
  • Supported Color Space Formats
  • Quality and Size Comparison
  • Related Info

    @@ -58,7 +59,7 @@ @@ -102,13 +108,14 @@ int ret = 0; int width = 0; int height = 0; unsigned int size_decode = 0; +image_util_decode_h decode_h = NULL;
  • -

    To find out which JPEG color spaces are supported on the device, use the image_util_foreach_supported_jpeg_colorspace() function:

    +

    To find out which color spaces are supported on the device, use the image_util_foreach_supported_colorspace() function:

    -int image_util_foreach_supported_jpeg_colorspace(image_util_supported_jpeg_colorspace_cb
    -                                                 callback, void * user_data);
    +int image_util_foreach_supported_colorspace(image_util_type_e image_type,
    +                                            image_util_supported_colorspace_cb callback, void *user_data);
     

    The possible color spaces are defined in the image_util_colorspace_e enumeration (in mobile and wearable applications).

    For more information about the YUV color space, see http://www.fourcc.org/yuv.php.

    @@ -116,8 +123,13 @@ int image_util_foreach_supported_jpeg_colorspace(image_util_supported_jpeg_color
  • To support the image_util_transform_run() function, which is used for all image transformations, set the source image and create a handle for it (to be used as the second parameter):

    -ret = image_util_decode_jpeg(SAMPLE_FILENAME, colorspace, &img_source,
    -                             &width, &height, &size_decode);
    +ret = image_util_decode_create(&decode_h);
    +ret = image_util_decode_set_input_path(decode_h, SAMPLE_FILENAME);
    +ret = image_util_decode_set_colorspace(decode_h, colorspace);
    +ret = image_util_decode_set_output_buffer(decode_h, &img_source);
    +
    +ret = image_util_decode_run(decode_h, &width, &height, &size_decode);
    +ret = image_util_decode_destroy(decode_h);
     
     ret = media_format_create(&fmt);
     ret = media_format_set_video_mime(fmt, colorspace);
    @@ -415,15 +427,8 @@ ret = image_util_transform_run(handle, src,
     
     
  • -
  • - -

    Handle the transformation results in the image_util_transform_completed_cb() callback, which is invoked after the transformation is complete.

    - -
  • - -
  • - -

    After the transformation is complete, destroy the transformation handle using the image_util_transform_destroy() function:

    +
  • Handle the transformation results in the image_util_transform_completed_cb() callback, which is invoked after the transformation is complete.

  • +
  • After the transformation is complete, destroy the transformation handle using the image_util_transform_destroy() function:

     ret = image_util_transform_destroy(handle);
    @@ -433,67 +438,195 @@ ret = image_util_transform_destroy(handle);
     
     
     
    -

    Decoding from a File or Memory

    +

    Decoding from a File or Memory

    -

    To decode a JPEG image:

    +

    To decode a JPEG, PNG, GIF, or BMP image:

    -
      +
      1. -

        To decode the image from a file, use the image_util_decode_jpeg() function. Manually allocate the memory for the image buffer based on a calculated buffer size.

        +

        Create a decoding handle using the image_util_decode_create() function:

        -ret = image_util_decode_jpeg(SAMPLE_FILENAME, colorspace, &img_source,
        -                             &width, &height, &size_decode);
        +image_util_decode_h decode_h = NULL;
        +ret = image_util_decode_create(decode_h);
         
      2. -

        To decode the image from memory, use the image_util_decode_jpeg_from_memory() function. Manually allocate the memory for the image buffer based on a calculated buffer size.

        +

        Set the image to the input path or buffer using the image_util_decode_set_input_path() or image_util_decode_set_input_buffer() function:

        -ret = image_util_decode_jpeg_from_memory(jpeg_buffer, jpeg_size, colorspace,
        -                                         image_buffer, width, height, size);
        +ret = image_util_decode_set_input_path(decode_h, path);
         
      3. -
    - -

    Encoding to a File or Memory

    - -

    To encode a rotated or flipped image:

    - -
      +
    • -
    • To encode the image to a JPEG file, use the image_util_encode_jpeg() function: +

      To save the decoded image, set the output buffer using the image_util_decode_set_output_buffer() function:

      -ret = image_util_encode_jpeg(img_flip_target, dest_width, dest_height,
      -                             colorspace, 100, OUTPUT_ROTATED_JPEG);
      +unsigned char *result = NULL;
      +ret = image_util_decode_set_output_buffer(decode_h, &result);
       
    • +

      Optionally, set the color space and JPEG downscale using the image_util_decode_set_colorspace() and image_util_decode_set_jpeg_downscale() functions:

      -

      To encode the image to memory in the JPEG format, use the image_util_encode_jpeg_to_memory() function:

      +
      +unsigned char *result = NULL;
      +ret = image_util_decode_set_colorspace(decode_h, IMAGE_UTIL_COLORSPACE_RGBA8888);
      +ret = image_util_decode_set_jpeg_downscale(decode_h, IMAGE_UTIL_DOWNSCALE_1_1);
      +
      +
      + Note +
      • Because of decoder limitations, color space setting and JPEG downscaling are only supported for JPEG images.
      • +
      • The default color space is IMAGE_UTIL_COLORSPACE_RGBA8888. PNG, GIF and BMP images are decoded to IMAGE_UTIL_COLORSPACE_RGBA8888.
      +
      +
    • +
    • +

      Execute the decoding using the image_util_decode_run() function:

      -ret = image_util_encode_jpeg_to_memory(img_flip_target, dest_width, dest_height,
      -                                       colorspace, 100, jpeg_buffer, jpeg_size);
      +unsigned long width = 0; /* Decoded image width */
      +unsigned long height = 0; /* Decoded image height */
      +unsigned long long size = 0; /* Decoded image size */
      +ret = image_util_decode_run(decode_h, &width, &height, &size);
       
      +
    • +
    • +

      After the decoding is complete, destroy the decoding handle using the image_util_decode_destroy() function:

      +
      +ret = image_util_decode_destroy(decode_h);
      +
      +
    • + +

      Encoding to a File or Memory

      +

      To encode a raw image:

      +
        +
      1. +

        Create an encoding handle using the image_util_encode_create() function:

        +
        +image_util_type_e encoder_type = IMAGE_UTIL_JPEG;
        +image_util_encode_h encode_h = NULL;
        +ret = image_util_encode_create(encoder_type, encode_h);
        +
        +
      2. +
      3. +

        Set the image to the input buffer using the image_util_encode_set_input_buffer() function:

        +
        +ret = image_util_encode_set_input_buffer(encode_h, buffer);
        +
        +
      4. +
      5. +

        Set the width, height, and color space of the input buffer using the image_util_encode_set_resolution() and image_util_encode_set_colorspace() functions:

        +
        +ret = image_util_encode_set_resolution(encode_h, width, height);
        +ret = image_util_encode_set_colorspace(encode_h, IMAGE_UTIL_COLORSPACE_RGBA8888);
        +
        +
        + Note +
        • Because of encoder limitations, color space setting is only supported for encoding JPEG images.
        • +
        • The default color space is IMAGE_UTIL_COLORSPACE_RGBA8888. PNG, GIF and BMP images are encoded with IMAGE_UTIL_COLORSPACE_RGBA8888.
        +
        +
      6. +
      7. +

        To save the encoded image, set the output path or buffer using the image_util_encode_set_output_path() or image_util_encode_set_output_buffer() function:

        +
        +ret = image_util_encode_set_output_path(encode_h, path);
        +
      8. +
      9. +

        Optionally, set the JPEG quality or PNG compression using the image_util_encode_set_quality() or image_util_encode_set_png_compression() function:

        -
    +
    +ret = image_util_encode_set_jpeg_downscale(decode_h, IMAGE_UTIL_DOWNSCALE_1_1);
    +
    +
    + Note +
    • Because of encoder limitations, quality setting is only supported for JPEG images, and compression is only supported for PNG images.
    • +
    • The default JPEG quality is 75. The default PNG compression is IMAGE_UTIL_PNG_COMPRESSION_6.
    +
    +
  • +
  • +

    Execute the encoding using the image_util_encode_run() function:

    +
    +unsigned long long size = 0; /* Encoded image size */
    +ret = image_util_encode_run(encode_h, &size);
    +
    +
  • +
  • +

    After the encoding is complete, destroy the encoding handle using the image_util_encode_destroy() function:

    +
    +ret = image_util_encode_destroy(encode_h);
    +
    +
  • + -

    Supported Colorspace Formats

    +

    Encoding an Animated GIF

    +

    To encode an animated GIF image:

    +
      +
    1. +

      Create an encoding handle using the image_util_encode_create() function:

      +
      +image_util_type_e encoder_type = IMAGE_UTIL_GIF;
      +image_util_encode_h encode_h = NULL;
      +ret = image_util_encode_create(encoder_type, encode_h);
      +
      +
    2. +
    3. + For each frame: +
        +
      1. +

        Set the image to the input buffer using the image_util_encode_set_input_buffer() function:

        +
        +ret = image_util_encode_set_input_buffer(encode_h, buffer);
        +
        +
      2. +
      3. +

        Set the width and height of the input buffer using the image_util_encode_set_resolution() function:

        +
        +ret = image_util_encode_set_resolution(encode_h, width, height);
        +
        +
      4. +
      5. +

        Set the delay time between GIF frames using the image_util_encode_set_gif_frame_delay_time() function:

        +
        +ret = image_util_encode_set_gif_frame_delay_time(encode_h, buffer);
        +
        +
      6. +
      +
    4. +
    5. +

      To save the encoded image, set the output path or buffer using the image_util_encode_set_output_path() or image_util_encode_set_output_buffer() function:

      +
      +ret = image_util_encode_set_output_path(encode_h, path);
      +
      +
    6. +
    7. +

      Execute the encoding using the image_util_encode_run() function:

      +
      +unsigned long long size = 0; /* Animated GIF image size */
      +ret = image_util_encode_run(encode_h, &size);
      +
      +
    8. +
    9. +

      After the encoding is complete, destroy the encoding handle using the image_util_encode_destroy() function:

      +
      +ret = image_util_encode_destroy(encode_h);
      +
      +
    10. +
    +

    Supported Color Space Formats

    -

    The following tables define the supported colorspace formats.

    +

    The following tables define the supported color space formats.

    Table: RGB pixel formats