Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Ian Ross has just released a book on Anim8or. It's perect for a beginner and a good reference for experienced users. It contains detailed chapters on every aspect, with many examples. Get your own copy here: "Anim8or Tutorial Book"

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

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 2124
    • View Profile
New Write Image Functions.
« on: March 13, 2019, 05: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: 1482
    • View Profile
Re: New Write Image Functions.
« Reply #1 on: March 13, 2019, 06: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: 2124
    • View Profile
Re: New Write Image Functions.
« Reply #2 on: March 13, 2019, 06:57:08 pm »

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

Raxx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1482
    • View Profile
Re: New Write Image Functions.
« Reply #3 on: March 13, 2019, 08:08:58 pm »

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 13, 2019, 08:10:04 pm by Raxx »
Logged

NickE

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: New Write Image Functions.
« Reply #4 on: March 14, 2019, 06: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