An image forming apparatus which performs pulsewidth modulation with a pulsewidth
set by counting a clock. Especially, for grayscale level correction by setting
the frequency of the clock, the periodic clock is counted, and an output pattern
is changed in accordance with a count value of the clock. Otherwise, information
corresponding to a clock pattern is stored in advance, and the information is sequentially
read and used as a clock. Otherwise, a clock source in which the frequency is controlled
by a control signal is used.