gpu.types.GPUOffScreen higher resolution and in separate window

I recently discovered the gpu.types.GPUOffScreen class and I’m trying to use it to simply render the 3D viewport into some images, my full code in python if you’re interested (

import base64, io, os, bgl, gpu, bpy, threading, time, sys
import numpy as np
from gpu_extras.presets import draw_texture_2d
from PIL import Image
import multiprocessing.pool as mpool

finalPath = bpy.context.scene.render.filepath + "hithere.png"

WIDTH = 512
HEIGHT = 256

offscreen = gpu.types.GPUOffScreen(WIDTH, HEIGHT)
area =[-1].screen.areas[0]
area.type = 'VIEW_3D'
def draw2():
    global finalPath
    global array
    global WIDTH
    global HEIGHT
    global needsSaving
    global area
    context = bpy.context
    scene = context.scene
    render = scene.render
    camera =

    view_matrix =

    projection_matrix =
        context.depsgraph, x=WIDTH, y=HEIGHT)

    draw_texture_2d(offscreen.color_texture, (0, 0), WIDTH, HEIGHT)
    buffer = bgl.Buffer(bgl.GL_BYTE, WIDTH * HEIGHT * 4)
    bgl.glReadPixels(0, 0, WIDTH, HEIGHT, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer)
    needle = threading.Thread(target=saveIt,args=[buffer, finalPath, WIDTH, HEIGHT])
    needle.daemon = True
    #thread.start_new_thread(saveIt,(buffer, finalPath, WIDTH, HEIGHT))

def coby(scene):
    frame = scene.frame_current
    folder = scene.render.filepath
    myFormat = "png"#scene.render.image_settings.renderformat.lower()
    outputPath = os.path.join(folder, "%05d.%s" % (frame, myFormat))
    global finalPath
    finalPath = outputPath

h = bpy.types.SpaceView3D.draw_handler_add(draw2, (), 'WINDOW', 'POST_PIXEL')

def saveIt(buffer, path, width, height):
    array = np.asarray(buffer, dtype=np.uint8)
    myBytes = array.tobytes()
    im = Image.frombytes("RGBA",(width, height), myBytes)
    rawBytes = io.BytesIO(), "PNG")
    base64Encoded = base64.b64encode(
    txt =  "data:image/png;base64," + base64Encoded.decode()
    f = open(finalPath, "wb")
and I also had to modify the source code as in this answer:

SO the thing is everything works if the WIDTH and HEIGHT are just left at the default, because then it doesn’t go out of the viewport and the image doesn’t get smeared… but when I change it to a resolution greater than the 3D view, the output looks something like this:

So as you can see it becomes smeared at the bottom when I ncrease the size, it seems to just be showing more of the 3D view instead of expanding the camera view… I Want to achieve a result similar to the viewport render, where it simply scales up the camera view to the desired resolution… I tried the scale_x and scale_y arguments, but they just made it look pixelated.

SO: if modifying the source code is necessary, how can I get an image buffer of the offscreen render at a higher resolution?