Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unsupported format for CGBitmapContextCreate



Hi,

I am trying to use CGBitmapContextCreate to create a context for a raw
image, but I get this error message:

CGBitmapContextCreate: unsupported parameter combination: 8 integer
bits/component; 32 bits/pixel; 3-component colorspace;
kCGImageAlphaFirst.

Here is how I create my color space

constructor TLCLBackend.Create;
var
loc: CMProfileLocation;
status: OSStatus;
begin
inherited;
........

{ Creates a generic color profile }

loc.locType := cmPathBasedProfile;
loc.u.pathLoc.path := STR_GenericRGBProfilePath;

status := CMOpenProfile(FProfile, loc);

if status <> noErr then raise Exception.Create('Couldn''t create the
generic profile');

{ Creates a generic color space }

FColorSpace := CGColorSpaceCreateWithPlatformColorSpace(FProfile);

if FColorSpace = nil then raise Exception.Create('Couldn''t create
the generic RGB color space');

end;


And how I finally use it to create the bitmap:

procedure TLCLBackend.InitializeSurface(NewWidth, NewHeight: Integer;
ClearBuffer: Boolean);
begin
{ We allocate our own memory for the image }
Stride := NewWidth * 4;
FBits := System.GetMem(NewHeight * Stride);

if FBits = nil then
  raise Exception.Create('Can''t allocate memory for the DIB');

FContext := CGBitmapContextCreate(FBits,
 NewWidth, NewHeight, 8, Stride, FColorSpace, kCGImageAlphaFirst or
kCGBitmapByteOrder32Little);

if FContext = nil then raise Exception.Create('Couldn''t create the
device context');

{ clear the image }
if ClearBuffer then
  FillLongword(FBits[0], NewWidth * NewHeight, clBlack32);
end;

Any ideas about what is wrong? i looked at CGBitmapContextCreate's
docs here, but they say that it supports 32-bits images with 8 bits
per channel:

http://developer.apple.com/documentation/GraphicsImaging/Reference/CGImage/Reference/reference.html#//apple_ref/doc/c_ref/CGBitmapInfo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.