Hi Jim,
Yes, I'm using a memory mapped file to avoid saving any intermediate file. Here is the pseudo-code which reads the SVG file and replaces all occurrences of one color (#C0C0C0) by another (#000000). String encoding is required as a memory mapped file is the byte array. There is one limitation in this approach - the size of the object which you replace should be of the same size as the object by which you replace. It was not the problem in this particular case though.
import mmap
import contextlib
bitmap_image = None
with open("test.svg", "r") as f:
with contextlib.closing(mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_COPY)) as m:
old_color = "#C0C0C0".encode()
pos = m.find(old_color)
new_color = "#000000"
while pos != -1:
m[pos : pos + len(new_color)] = new_color.encode()
pos = m.find(old_color)
bitmap_image = pygame.image.load(m).convert_alpha()
Best regards