Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

An update to Anim8or, v1.00b, is available with a few bug fixes. Get your copy HERE. See the "ReadMe" file for details.

Author Topic: New Write Image Functions.  (Read 2596 times)

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 1736
    • View Profile
New Write Image Functions.
« on: March 13, 2019, 09:47:45 pm »

In the latest development build 1356 you can save rendered images in BMP, JPG and PNG format.

class image {
    int WriteBMP(string fName); // All functions return 1 if OK, 0 if failed
    int WriteJPG(string fName [ , int quality = 95 ] ); // 0 = lowest, 100 = highest
    int WritePNG(string fName [, int IncludeAlpha = 0 ] );
}

image GetImage(int image_id); // Returns NULL if no such image.
enum image_id { IMAGE_COLOR, IMAGE_ALPHA, IMAGE_DEPTH };

I've attached a sample script.

Logged

Raxx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1477
    • View Profile
Re: New Write Image Functions.
« Reply #1 on: March 13, 2019, 10:48:23 pm »

Very cool, I always like to see ASL enhancements. Are there any plans on extending the image class to include the ability to create images from scratch, and functions for reading and manipulating pixels?
Logged

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 1736
    • View Profile
Re: New Write Image Functions.
« Reply #2 on: March 13, 2019, 10:57:08 pm »

That's a thought. What kind of functions did you have in mind? Compositing?
Logged

Raxx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1477
    • View Profile
Re: New Write Image Functions.
« Reply #3 on: March 14, 2019, 12:08:58 am »

I don't really (read: never) deal with image processing via code. I expect for starters, something like:

new data types:
byte: unsigned 8-bit integer (0-255)
struct pixel {
 byte r, g, b, a;
}

creation:
image $img;
$img.Read(fileName);
$img.New(width, height) or $img = Image(width, height) - Width/height can only be set during this stage. Construction creates blank and transparent pixels (zeroes across the rgba channels)

fields/properties:
$img.width (read only)
$img.height (read only)
$img.pixels[] (get/set array values, but protected array size). Array length is width*height

Manipulation aside from $img.pixels[]:
$img.GetPixel(x, y) - user-friendly means of getting pixels by its x and y coordinates in the image.
$img.SetPixel(x, y, pixel) - user friendly means of setting the pixel

Maybe also tie this class into textures as well, as it expands capability to create procedural and possibly (scratches head) animated textures? For example, $tex.SetTexture($img) uses an Image object for its image information rather than a file.
« Last Edit: March 14, 2019, 12:10:04 am by Raxx »
Logged

NickE

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: New Write Image Functions.
« Reply #4 on: March 14, 2019, 10:34:39 pm »

Yea!  You rock, Steve! This solves many of the problems with rendering script-driven physics simulations.  I used to have to start an object script, manually switch to scene mode and start rendering, then remove all the duplicate frames from the scene rendering as the object script ran in the background with strategic delays to give the renderer time to finish the frame before the object script incremented.

Ideally, the scene controller parameters "frame" or "time" would be available to object scripts from scene mode, but this is a huge step forward.

Thank you, Steve!
Logged