In a standard Rayleigh-Benard experiment, a layer of fluid is confined between two horizontal plates and the convection regime is controlled by the temperature difference between the hot lower plate and the cold upper plate. The effect of direct heat injection into the fluid layer itself, for example by light absorption, is studied here theoretically. In this case, the Nusselt number (Nu) depends on three non-dimensional parameters: the Rayleigh (Ra) and Prandtl (Pr) numbers and the ratio between the spatial extension of the heat source (l) and the height of the fluid layer (h). For both the well-known classical and ultimate convection regimes, the theory developed here gives a formula for the variations of the Nusselt number as a function of these parameters. For the classical convection regime, by increasing l/h from 0 to 1/2, Nu gradually changes from the standard scaling Nu similar to Ra-1/3 to an asymptotic scaling Nu similar to Ra-0, with theta = 2/3 or theta = 1 by adopting, respectively, the Malkus (Proc. R. Soc. A, vol. 225, 1954, pp. 196-212) theory or the Grossmann & Lohse (J. Fluid Mech., vol. 407, 2000, pp. 27-56) theory. For the ultimate convection regime, Nu gradually changes from Nu similar to Ra-1/2 scaling to an asymptotic behaviour seen only at very high Ra for which Nu similar to Ra-2. This theory is validated by the recent experimental results given by Bouillaut et al. (J. Fluid Mech., vol. 861, 2019, R5) and also shows that for these experiments, Ra and Re numbers were too small to observe the ultimate regime. The predictions for the ultimate regime cannot be confirmed at this time due to the absence of experimental or numerical work on convection driven by internal sources and for very large Ra numbers.