A non-transitory computer program product comprising a computer usable medium having computer readable program codes embodied in the medium for forming an image in an image forming apparatus including a counter that counts number of times of forming a latent image of input image data in a sub-scanning direction in which an upper limit of the number of times is set, the computer readable program codes when executed causing a computer to execute:
- forming a latent image of input image data;
- first controlling including controlling the forming to form the latent image based on the upper limit;
- determining whether a latent image forming is performed exceeding the upper limit;
- and
- second controlling including controlling, when it is determined that the latent image forming is performed exceeding the upper limit, the forming to continue to form the latent image,
- wherein the second controlling further includes
- making a determination based on a flag that indicates whether the latent image forming is performed exceeding the upper limit, and
- validating, when the flag is in an active state, a sub-scanning image-data transfer valid area, a sub-scanning write valid area, and a sub-scanning write trim area independently of a control by the counter.