I made a scrolling tile 2D video game in visual basic a few years back. I am translating it to Cocoa for the Mac. Is there a framework that would allow me to use BitBlt? Or is there an equivalent to BitBlt without using OpenGL? Thanks!
BitBlt() equivalent in Objective-C/Cocoa
2.5k views Asked by Brian At
2
There are 2 answers
0
Doug Richardson
On
As Matt mentioned, you probably want CGContextDrawImage and CGContextSetBlendMode.
First, you need to create a CGImageRef from the image data. You do this with a data provider. If you already have the image loaded in memory, then you should use CGDataProviderCreateDirect. That data provider will be a parameter to CGImageCreate.
Next, in your Cocoa view's drawRect: method, you'll want to get the current context like this:
CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
Then use CGContextDrawImage to draw the image.
As Matt mentioned, you can control blending with CGContextSetBlendMode.
Related Questions in OBJECTIVE-C
- How to control the volume of an iPhone programmatically in objective-c
- Occasional crash at NSURLSessionDataTask dataTaskWithRequest:completionHandler:
- How to set value the descriptor of iOS BLE in Objective-C?
- Unexpected #selector() Behavior in Swift-Objective-C Interop?
- In what context can we use an unqualified #selector() expression in Swift?
- AVPictureInPictureController crashes during initialization
- How to use pow() in Objective-C?
- How to change the image on the MGSwipeButton in MGSwipeTableCell
- Using sort descriptors in Outline View
- Why is my Swift function not printing from inside the dataTask closure?
- Using UICollectionViewCell with IBOutlet
- Undefined symbol: _OBJC_CLASS_$_ only on simulator
- Why can't I receive a notification sent from Camera Extension(Swift) to an observer application (obj-c++)
- Behavior of __block modifier in objc
- Inserting subview into view where I've added subviews and sublayers
Related Questions in COCOA
- In what context can we use an unqualified #selector() expression in Swift?
- How can I trigger macOS system gamepad API based on a value received from iOS app through core bluetooth
- Using sort descriptors in Outline View
- NSTableView to NSOutlineView Drag & Drop not accepting drop
- How to remove horizontal line in bottom of section NSTableView?
- CGSRegionRef: How is an arbitrary region represented as union of rects?
- Listen for Touch Events on MacOS (Trackpad)
- Window "yanks" when moving
- Writing NSFilePromiseProviders to pasteboard blocks app on quit
- Basic ImGui program doesn't render, leaks memory and crashes
- NSTokenField suggestion using context menu in swift
- How to link multiple text views to a single text storage in TextKit 2
- I would like to know why I’m not getting IBOutlets connected in an App’s window
- How to make a custom event loop in Cocoa?
- Why is restoreWindow(withIdentifier:state:) called after applicationDidFinishLaunching(_:)?
Related Questions in MACOS
- Error installing Nativescript on Mac M2 Sonoma 14.4.1
- macOS - Most secure way of a GUI SUDO_ASKPASS
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Why does Hugo generate different taxonomy-related HTML on different OS's?
- ZSH function parameters conundrum
- how to make read only file/directory in Mac writable
- macOS BigSur - Unable to run bundled php version or brew php 8
- 9 Digit Addresses in Hexadecimal System in MacOS
- MacOS Bash-Script: while read p and echo
- How to make a range for tail rows on a categorized table in Numbers with JXA scripts?
- Cannot build a basic project with curl on Mac (M2) for Raspberry Pi Pico
- How to recover deleted files from create vite react project
- Can't run built SFML project from Xcode template
- React Native - RealmJS - Linker command failed with exit code 1
- How can I manually add a keyboard shortcut to a Shortcut Action Service directly via the system files, without going through the System Prefs GUI?
Related Questions in GRAPHICS
- How to fix "Access violation executing location" when using GLFW and GLAD
- Why is the value of `gl_FragCoord.z` is always 0.5?
- A way to warp an image based on a map
- Spacing out overlapping rectangles: how to translate pseudocode?
- 3D graph in Rstudio (time vs intensity vs coefficient)
- I want to create a creative website based on my project. I am new in this field
- Color each field in a mosaic plot in R
- How to convert raw RGB luminance using OCIO
- CPU Ray Tracer finds intersection for only a certain setup
- How do I dynamically change vertex colors using Direct3d 12 and Visual C++?
- Python Mediapipe replace chest pose landmark lines with custom image
- I was following Computer Graphics from Scratch -- Getting distorted spheres
- Convert coordinates in android
- Python Mediapipe replace pose landmark line drawings with custom image drawings
- Is there a way to automatically export OpenOffice/LibreOffice drawings to bitmaps, with options?
Related Questions in BITBLT
- BitBlt Memory leak
- Qt: Alternative to BitBlt in Qt5 Windows
- Which Windows API capturing screen faster than Bitblt or any other Mirror Drivers?
- How to get bitblt to copy child controls without painting the child controls to the screen?
- How is mouse rendered in windows
- Win32 Double Buffering drawing black background
- Screen capture of windows media player version 12
- Multiple HDCs into one HDC to Bitblt in MFC
- screenshot can't be captured when winlogon screen is displayed
- BitBlting with Windows Aero
- Using BitBlt to capture screenshot, how?
- How do I perform BitBlt() to copy a screen region that contains Windows Media Player in win32 C++ programming?
- Detect game hack through screenshot analysis C#
- Capture a Form to a Bitmap after the Form has been resized
- BitBlt() equivalent in Objective-C/Cocoa
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
You should probably start with Core Graphics