---
title: "QLThumbnailRequestCreateContext(_:_:_:_:)"
framework: quicklook
role: symbol
role_heading: Function
path: "quicklook/qlthumbnailrequestcreatecontext(_:_:_:_:)"
---

# QLThumbnailRequestCreateContext(_:_:_:_:)

Creates a graphics context to draw the thumbnail in.

## Declaration

```swift
func QLThumbnailRequestCreateContext(_ thumbnail: QLThumbnailRequest!, _ size: CGSize, _ isBitmap: Bool, _ properties: CFDictionary!) -> Unmanaged<CGContext>!
```

## Parameters

- `size`: The size of the thumbnail; if isBitmap is true the size is in pixels, otherwise it’s in points.
- `isBitmap`: true if the thumbnail data is bitmap-based, false if vector-based. This value of this parameter affects the interpretation of the size parameter.
- `properties`: A dictionary containing properties for the thumbnail response. For macOS 10.5, no properties have been defined.

## Return Value

Return Value A Core Graphics graphics-context object that you can draw your thumbnail image in. You should explicitly release this object when it is no longer needed.

## Discussion

Discussion You can directly draw your thumbnail data in the graphics-context object created by this function. After calling this function, you should flush the context with QLThumbnailRequestFlushContext(_:_:). Also be sure to release the CGContext object. With this function you can create two types of graphics contexts for drawing thumbnails: bitmap and single-page vector-based; you use the isBitmap flag to distinguish between the two. Quick Look handles bitmap thumbnail context differently than non-bitmap contexts; in the latter case, Quick Look might scale the drawing up or down if necessary, and it respects the scale factor (for HiDPI support). If you prefer to work in Objective-C code, you can convert the created CGContext to a NSGraphicsContext object using init(graphicsPort:flipped:). Special Considerations Thread-safety: This function should be called in the same thread as the thumbnail request is made in; generally, this is the same thread in which the GenerateThumbnailForURL callback was invoked.

## See Also

### Handling thumbnail requests

- [QLThumbnailRequestCopyContentUTI(_:)](quicklook/qlthumbnailrequestcopycontentuti(_:).md)
- [QLThumbnailRequestCopyOptions(_:)](quicklook/qlthumbnailrequestcopyoptions(_:).md)
- [QLThumbnailRequestCopyURL(_:)](quicklook/qlthumbnailrequestcopyurl(_:).md)
- [QLThumbnailRequestFlushContext(_:_:)](quicklook/qlthumbnailrequestflushcontext(_:_:).md)
- [QLThumbnailRequestGetDocumentObject(_:)](quicklook/qlthumbnailrequestgetdocumentobject(_:).md)
- [QLThumbnailRequestGetGeneratorBundle(_:)](quicklook/qlthumbnailrequestgetgeneratorbundle(_:).md)
- [QLThumbnailRequestGetMaximumSize(_:)](quicklook/qlthumbnailrequestgetmaximumsize(_:).md)
- [QLThumbnailRequestGetTypeID()](quicklook/qlthumbnailrequestgettypeid().md)
- [QLThumbnailRequestIsCancelled(_:)](quicklook/qlthumbnailrequestiscancelled(_:).md)
- [QLThumbnailRequestSetDocumentObject(_:_:_:)](quicklook/qlthumbnailrequestsetdocumentobject(_:_:_:).md)
- [QLThumbnailRequestSetImage(_:_:_:)](quicklook/qlthumbnailrequestsetimage(_:_:_:).md)
- [QLThumbnailRequestSetImageAtURL(_:_:_:)](quicklook/qlthumbnailrequestsetimageaturl(_:_:_:).md)
- [QLThumbnailRequestSetImageWithData(_:_:_:)](quicklook/qlthumbnailrequestsetimagewithdata(_:_:_:).md)
- [QLThumbnailRequestSetThumbnailWithDataRepresentation(_:_:_:_:_:)](quicklook/qlthumbnailrequestsetthumbnailwithdatarepresentation(_:_:_:_:_:).md)
- [QLThumbnailRequestSetThumbnailWithURLRepresentation(_:_:_:_:_:)](quicklook/qlthumbnailrequestsetthumbnailwithurlrepresentation(_:_:_:_:_:).md)
