The battery charging animation is usually a series of images, displayed in the status bar. Assuming that you are talking about them (the images in the status bar), they are animated when an event is broadcast.
Giving some more detail, whenever a charger is connected, an intent is broadcast, which is received by the SystemUI to animate the status bar's battery indicator image. When a charger is disconnected, another intent is broadcast so as to stop the SystemUI from animating the battery indicator images.
All of this is handled by the file BatteryService.java in frameworks/base of the android source.
The other charging animation that you are talking about, is when an image is displayed on the screen when the screen is turned off, but the charger is connected. This is usually known as off-mode charging, which takes over the framebuffer, and draws an image over it, according to two conditions:
1. charger is connected
2. display is turned off
Answering the second part of your question, the former method, BatteryService.java is in userspace, and you can not do much about it; as booting up the phone with only one service, and it showing the charging images. The latter, if exists on your device, would be when your phone is turned off, and connected to a charger, it usually boots up into the recovery, where it is 'checked' at boot time init whether the charger is present/not, and usually, shows the charging images.