mirror of
https://github.com/jorio/Pomme.git
synced 2024-12-27 21:31:47 +00:00
Add GetPictureFromFile (extension)
This commit is contained in:
parent
f3a070072b
commit
ad669a3fd4
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
#include <PommeFiles.h>
|
||||
|
||||
using namespace Pomme;
|
||||
using namespace Pomme::Graphics;
|
||||
@ -123,14 +124,9 @@ static UInt32 GetEightColorPaletteValue(long color)
|
||||
// ---------------------------------------------------------------------------- -
|
||||
// PICT resources
|
||||
|
||||
PicHandle GetPicture(short PICTresourceID)
|
||||
static PicHandle GetPictureFromStream(std::istream& stream, bool skip512)
|
||||
{
|
||||
Handle rawResource = GetResource('PICT', PICTresourceID);
|
||||
if (rawResource == nil)
|
||||
return nil;
|
||||
memstream substream(*rawResource, GetHandleSize(rawResource));
|
||||
ARGBPixmap pm = ReadPICT(substream, false);
|
||||
ReleaseResource(rawResource);
|
||||
ARGBPixmap pm = ReadPICT(stream, skip512);
|
||||
|
||||
// Tack the data onto the end of the Picture struct,
|
||||
// so that DisposeHandle frees both the Picture and the data.
|
||||
@ -148,6 +144,32 @@ PicHandle GetPicture(short PICTresourceID)
|
||||
return ph;
|
||||
}
|
||||
|
||||
PicHandle GetPicture(short PICTresourceID)
|
||||
{
|
||||
Handle rawResource = GetResource('PICT', PICTresourceID);
|
||||
if (rawResource == nil)
|
||||
return nil;
|
||||
|
||||
memstream stream(*rawResource, GetHandleSize(rawResource));
|
||||
PicHandle ph = GetPictureFromStream(stream, false);
|
||||
ReleaseResource(rawResource);
|
||||
return ph;
|
||||
}
|
||||
|
||||
PicHandle GetPictureFromFile(const FSSpec* spec)
|
||||
{
|
||||
short refNum;
|
||||
|
||||
OSErr error = FSpOpenDF(spec, fsRdPerm, &refNum);
|
||||
if (error != noErr)
|
||||
return nil;
|
||||
|
||||
auto& stream = Pomme::Files::GetStream(refNum);
|
||||
PicHandle ph = GetPictureFromStream(stream, true);
|
||||
FSClose(refNum);
|
||||
return ph;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------- -
|
||||
// Rect
|
||||
|
||||
|
@ -114,8 +114,13 @@ void OffsetRect(Rect* r, short dh, short dv);
|
||||
// ----------------------------------------------------------------------------
|
||||
// QuickDraw 2D: PICT
|
||||
|
||||
// Read picture from 'PICT' resource.
|
||||
PicHandle GetPicture(short PICTresourceID);
|
||||
|
||||
// Read a picture from a PICT file on disk.
|
||||
// Pomme extension (not part of the original Toolbox API).
|
||||
PicHandle GetPictureFromFile(const FSSpec* spec);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// QuickDraw 2D: GWorld
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user