IPhone SDK: How to create an image from raw data

Creating a UIImage from some form of bitmap file format is easy, whether you let UIImage load the file itself or create it with an NSData. But what if you have raw bitmap data in memory and you want to create an image?
In Cocoa NSBitmapImageRep can be created by passing it a pointer to a block of memory and the relevant heigh, width, bit depth etc. information. From that you can easily create an NSImage. There doesn't seem to be anything equivalent on the iPhone. CGImage can be created but it looks like you have to write a CGImageProvider. CGBitmapContextCreate takes a void * to a block of memory. Does it clear that block?
Is there a good way to do this?

ElNono wrote:
You can't do RGB565 on a CGImageRef/CGContextRef. The only 5bpp modes supported are 1555 ARGB or 5551 RGBA. If you just need to display the image, use OpenGL. One of the supported texture formats is RGB565. If you need to save the image then you're going to have to pre-convert it to RGB888.
hi ElNono , i have test the RGB888 data now , the image can show , but another problem is the image just like serveral picture over lap together , also is blurred , my code is here:
const size_t width = 1024;
const size_t height = 768;
const size_t bitsPerComponent = 8;
const size_t bitsPerPixel = 32;
const size_t bytesPerRow = (bitsPerPixel * width)/8;
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSString *imagePath = [[NSBundle mainBundle] pathForResource: @"Test" ofType: @"rgb"];
NSFileHandle* file = [NSFileHandle fileHandleForReadingAtPath:imagePath];
NSData* imageData = [file readDataToEndOfFile];
CGContextRef context = CGBitmapContextCreate((void*)[imageData bytes], width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo);
CGImageRef imageRef = CGBitmapContextCreateImage (context);
UIImage*rawImage = [UIImage imageWithCGImage:imageRef];
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
CGImageRelease(imageRef);

Similar Messages

  • How to create an image from another one with midp1.0 as in midp 2.0

    hi:
    we can create an image from part of another one in midp2.0 width the following method
    createImage(Image image, int x,int y,int width,int height,int transform)
    but have to work with midp1.0, then how?
    regards

    but i have six icons in one picture, (tow row ,three column, each size 14*14)
    it's ok to get the top-left icon with the following code
    Image image = Image.createImage("/myicon.png");
    Image tmp = Image.createImage(14, 14);
    Graphics g = tmp.getGraphics();
    g.drawImage(image, 0, 0, Graphics.TOP|Graphics.LEFT);
    but how to get other icon?
    regards

  • [SOLVED] How to Create an Image from UTF8 Text via Command-line

    As the title points out, I'm trying to create an image from unicode text via command line. I tried...
    convert -pointsize 48 -size 400 caption:测试用 text.png
    But that results in question marks for the Chinese characters. So searching around online I discovered that I needed to specify a font which could display the characters. The characters show up just fine in Firefox, KDE, Kate, Terminal, etc so I know I have a font which can render them. I thought it might be DejaVu but this also resulted in question marks...
    convert -font /usr/share/fonts/TTF/DejaVuSerif.ttf -pointsize 48 -size 400 caption:测试用 text.png
    Any ideas?
    Last edited by tony5429 (2011-01-31 23:17:41)

    DejaVu doesn't contain those Chinese glyphs at all, so please don't blame ImageMagick for not rendering them.
    So, Firefox, Kate, Terminal and the others you stated to use DejaVu, if encounter these characters, fall back to some other fonts to render them. These fonts are, however, not vector, but bitmap fonts. (This can be seen if you increase text size (Ctrl++ in Firefox): the Chinese characters don't change, they remain of their inherent size.)
    Actually, e.g. /usr/share/fonts/misc/18x18ko.pcf.gz definitely contains the three example characters, so the mentioned apps may use this font as fall back.
    Apparently ImageMagick doesn't handle bitmap fonts (I'm not sure), so you won't be able to hit your original target. Anyway, since you tried to parse "-pointsize 48", you wouldn't be satisfied with the font size.
    Your only choice seems to be using the above mentioned CJK-approved TTFs.
    EDIT: typo
    Last edited by barto (2011-01-28 21:52:33)

  • [IPhone SDK] How to create dylib on iPhone

    Hi all,
    I am developing an iPhone application. I need to put some of the code in a dylib and link it to my application project.
    How do I create dylib using xcode and how do I link it to my application?
    Thanks for ur help in advance.

    I don't believe you can, at this time, use your own dylibs or frameworks. You'll need to use static libraries instead.
    rob.

  • Create an Image from a Component

    Can anybody tell me how to create an Image from a Component?
    I intend to create an Image from a JTable now but I want to have a more generic solution of course to be able to create an Image from any Java / Swing component (Applet, JList, JButton, ...).
    Thank you,
    Dirk

    2 ways:
    1) java.awt.Toolkit.createScreenCapture(Rectangle bounds)
    2) This:
         public static BufferedImage grabByPaint(Component comp) {
              boolean visible = comp.isVisible();
              // if not visible, need to make visible to make sure sizes are correct. 
              if(!visible) {
                   comp.setVisible(true);
              Dimension size = comp.getSize();
              BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
              Graphics2D g2d = bi.createGraphics();
              comp.paintAll(g2d);
              if(!visible) {
                   comp.setVisible(false);
              g2d.dispose();
              return bi;
         }

  • How do you load images from a Win7 machine to iPhone?

    Hi. How do you load images from a Windows 7 PC to an iPhone 4? I'd like to load the pictures to use as wallpapers. Thanks.

    You CANNOT transfer photos from your computer to your iPhone when connected to your computer as an external drive. This is for transferring photos and/or video from your iPhone's Camera Roll to your computer's hard drive ONLY.
    To transfer photos from your computer's hard drive to your iPhone, this is selected under the Photo's tab for your iPhone's sync preferences with iTunes followed by a sync.

  • How can I download images from my iphone to adobe bridge cs5

    How can I download images from my iphone to adobe bridge cs5?  I don't want to use iPhoto.

    "How can I download photos from my iphone to mac?"
    Same way as with any other digital camera.
    "Do I need to use Iphoto? "
    Yes.
    "Why doesn't my Mac come with Iphoto application? "
    It does. All macs come with iphoto.
    Copying personal photos and videos from iOS devices to your computer

  • How I can load images from Creative Cloud storage in photoshop plugin, created in Extension Builder 3 with use html5/css/js?

    How I can load images from Creative Cloud storage in photoshop plugin, created in Extension Builder 3 with use html5/css/js ?

    At this point there is no API for accessing the cloud storage outside Adobe's own closed loop.
    Mylenium

  • How can I import images from iphoto with the albums and folders?

    How can I import images from iphoto without losing the albums and folders I already created?

    In Organizer, you can choose File>get Photos and Videos>From iPhoto.
    Importing from iPhoto'09: If in iPhoto, you organize your media using photo references, that is, the media actually does not reside inside iPhoto library package, and are referenced through original locations, Organizer does not create new copies of those media and just refer to the original location. but if your iPhoto media reside inside iPhoto library, Organizer creates a copy all media in your pictures folder, also imports albums and tags and other metadata.
    Importing from iPhoto'011: In this case, Organizer always creates a copy of your photos in your pictures folder which resides inside iPohto package. It does not import the albums and other metadata like star rating, caption etc.
    Hope this information helps!
    regards,
    vaishali

  • Can iDVD create disc images from VIDEO_TS folder, and burn them?

    That first question is pretty self-explanatory.
    Background is this: I've downloaded some video folders/files from forum/torrent trading websites. When finished, I have a VIDEO_TS folder, often an EXTRAS_TS folder as well. A while back, I downloaded the app DVD IMAGER to create a disc image. Yesterday that stopped working effectively, so maybe I need to re-download, but I was wondering if there's just a better way? I also downloaded the app called BURN, but can't see yet how that creates disc images.
    Once I create that disc image, I need to burn it, and I was using Disk Utility for that. I'm really looking for some help and advice on the best way to perform these processes.
    Thank you, and let me know if I need to post in another forum.

    Additionally, do you have experience w/ DVD Imager?
    Nope. Like I said, Roxio's Toast Titanium is the top application (and is probably the one that most experienced people use).

  • How to create an Image that is available to multiple locations?

    I can create an image from a virtual machine, but this image is only available to the location where the virtual machine was originally created (for example East US).
    I want to create a single image that is available to multiple locations (East US, North Europe, Southeast Asia, etc...)
    Is this possible?  I've noticed that stock images are available to multiple locations, can user images be configured in the same way?
    Thanks

    hi,
    As far as I know, it is not supported currently. But you could use a compromise method. You could copy the Image into other regions storage account. Then you could create the VM using yourself Image. But you may be charged the outbound data. I recommend
    you could refer to this thread (http://social.msdn.microsoft.com/Forums/en-US/04956637-45c5-40c9-9422-5b1c4de681bf/how-to-move-virtual-machine-to-a-different-region?forum=WAVirtualMachinesforWindows
    Hope it helps.
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to read some images from file system with webdynpro for abap?

    Hi,experts,
    I want to finish webdynpro for abap program to read some photos from file system. I may make MIMES in the webdynpro component and create photos in the MIMES, but my boss doesn't agree with me using this way. He wish me read these photos from file system.
    How to read some images from file system with webdynpro for abap?
    Thanks a lot!

    Hello Tao,
    The parameter
       icm/HTTP/file_access_<xx>
    may help you to access the pictures without any db-access.
    The following two links may help you to understand the other possibilities as well.
    The threads are covering BSP, but it should be useful for WebDynpro as well.
    /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
    http://help.sap.com/saphelp_sm40/helpdata/de/c4/87153a1a5b4c2de10000000a114084/content.htm
    Best regards
    Christian

  • How do i delete images from camera after importing

    how do i delete images from camera, ipad, iphone after importing the files into aperture3?

    Image capture will allow you to delete from the device after import, but I believe it is by design that Aperture does not do this as it is recommended (in the case of a camera) to use a device's own delete function rather than a 3rd party like Aperture. This also allows time for a proper backup before everything is erased from the device?

  • When I  put apps from my PC to my iPhone it copies it but it doesn't install in my phone??? I just my iPhone 5s so when i put images from my laptop I cant delete them so can you help me??

    When I  put apps from my PC to my iPhone it copies it but it doesn't install in my phone??? I just my iPhone 5s so when i put images from my laptop I cant delete them so can you help me??

    You might not have enough space on your phone. 
    Look on iTunes and see how much space the photos you copied over is consuming.

  • My storage is almost full on iphone. How do I delete photos from icloud?

    My storage is almost full on iphone. How do I delete photos from icloud?

    You can just tap Delete Back Up, you don't need to turn off iCloud.
    Deleting the backup only permanently deletes the backup from iCloud.  It doesn't do anything the the data currently on your phone.  You will want to create a new backup as soon as possible after doing this, however, as you won't have one until your do.  You can either intiate this manually to create one immediately by connecting your phone to your charger and to wifi, then going to Settings>iCloud>Storage & Backup and tapping Back Up Now at the bottom (this will take some time to complete the first time), or you can just connect it to your charger and wifi before you go to bed and it should back up automatically (and continue to do so once daily).
    You don't need to manually connect your phone to your computer to back up to wifi, but it's a good idea to create a second backup using iTunes occasionally in case your iCloud backup ever fails (I do this weekly).  To do this, connect your phone to your computer, open iTunes, click on the name of your phone in iTunes, go to the Summary tab of your iTunes sync settings and click Back Up Now.  (Your phone will continue to automatically back up to iCloud daily; this is just a second, manual backup, on your computer.)

Maybe you are looking for