Example #1
0
static void ItemStorage_LoadPalette(void)
{
    u16 arr[] = {
        0x5294,
        0x6B5A,
        0x7FFF
    };

    LoadPalette(&arr[2], 0xDF, 2);
    LoadPalette(&arr[1], 0xD1, 2);
    LoadPalette(&arr[0], 0xD8, 2);
}
Example #2
0
void TrackCompiler::AddBackgroundImage(std::istream &in, Parcel::ObjStream &archive)
{
	TrackSpecParser parser(in);

	if(parser.GetNextClass("HEADER") == NULL) {
		throw TrackCompileExn(_("Unable to find [HEADER] section"));
	}
	if(!parser.GetNextAttrib("Background")) {
		throw TrackCompileExn(_("Unable to find background image filename"));
	}
	std::string bgFilename = parser.GetParams();

	FILE *bgFile = fopen(bgFilename.c_str(), "rb");
	if (bgFile == NULL) {
		throw TrackCompileExn(boost::str(
			boost::format(_("Unable to find background image: %s")) %
				bgFilename));
	}

	// Extract the palette and image from the input file
	try {
		boost::scoped_array<MR_UInt8> bitmap(LoadBitmap(bgFile));
		boost::scoped_array<MR_UInt8> palette(LoadPalette(bgFile));

		archive << (int) MR_RAWBITMAP;
		archive.Write(palette.get(), MR_BACK_COLORS * 3);
		archive.Write(bitmap.get(), MR_BACK_X_RES * MR_BACK_Y_RES);
	}
	catch (...) {
		fclose(bgFile);
		throw;
	}

	fclose(bgFile);
}
Example #3
0
Bool PaletteSubDialog::CoreMessage(Int32 id, const BaseContainer& msg)
{
    switch ( id )
    {
      case  PALETTE_ID:
			Int64 color =  (Int64) msg.GetVoid( BFM_CORE_PAR1 );
			Int64 palette = (Int64) msg.GetVoid( BFM_CORE_PAR2 );
            if( palette == -1){
                BaseContainer *bc = GetActiveDocument()->BaseList2D::GetDataInstance()->GetContainerInstance(PALETTE_SCENE_HOOK_ID)->GetContainerInstance(m_id);
                if(bc != nullptr){
                    FromContainer(*bc);
                } else {
                    BaseContainer tmp;
                    m_paletteID = 0;
                    m_rows = 1;
                    m_layout = 0;
                    m_searchString = "";
                    m_showLabel = FALSE;
                    ToContainer(tmp);
                    GetActiveDocument()->BaseList2D::GetDataInstance()->GetContainerInstance(PALETTE_SCENE_HOOK_ID)->SetContainer(m_id,tmp);
                    FromContainer(tmp);
                }
            }
			if((palette == m_paletteID || palette == -1) && color == -1){
				LoadPalette(m_paletteID);
			}
        break;
    }
    return GeDialog::CoreMessage( id, msg );
}
Example #4
0
static void sub_810CE78(u8 taskId)
{
    REG_DISPCNT = 0;
    LZ77UnCompVram(gCaveTransitionTiles, (void *)0x600C000);
    LZ77UnCompVram(gCaveTransitionTilemap, (void *)0x600F800);
    LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20);
    LoadPalette(gUnknown_083F809C, 0xE0, 0x10);
    REG_BLDCNT = 15937;
    REG_BLDALPHA = 0;
    REG_BLDY = 0;
    REG_BG0CNT = 7948;
    REG_DISPCNT = 4416;
    gTasks[taskId].func = sub_810CF18;
    gTasks[taskId].data[0] = 16;
    gTasks[taskId].data[1] = 0;
}
Example #5
0
static void Load() {
  WORD i;

  screen[0] = NewBitmap(WIDTH, HEIGHT, DEPTH);
  screen[1] = NewBitmap(WIDTH, HEIGHT, DEPTH);

  for (i = 0; i < PNUM; i++)
    greeting[i].bitmap = LoadILBMCustom(greeting[i].filename, BM_DISPLAYABLE);

  background = LoadILBMCustom("data/neons.ilbm", BM_DISPLAYABLE|BM_LOAD_PALETTE);
  palette[0] = background->palette;
  palette[1] = LoadPalette("data/greet_moods.ilbm");
  palette[2] = LoadPalette("data/greet_rno.ilbm");

  PositionGreetings();
}
Example #6
0
static void Init() {
  float lightRadius = 1.0f;
  int i;

  canvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT);
  PixBufClear(canvas);

  uvmap = NewUVMap(WIDTH, HEIGHT, UV_FAST, 256, 256);
  UVMapGenerateTunnel(uvmap, 32.0f, 3, 4.0 / 3.0, 0.5, 0.5, NULL);
  UVMapSetTexture(uvmap, texture);

  flare = NewPixBuf(PIXBUF_GRAY, 64, 64);
  GeneratePixels(flare, (GenPixelFuncT)LightLinearFalloff, &lightRadius);
  for (i = 0; i < flare->width * flare->height; i++)
    flare->data[i] /= 4;

  origU = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);
  PixBufBlit(origU, 0, 0,
             NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.u), NULL);

  origV = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);
  PixBufBlit(origV, 0, 0,
             NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.v), NULL);

  InitDisplay(WIDTH, HEIGHT, DEPTH);
  LoadPalette(texturePal);
}
Example #7
0
void Surface::Set(const void* pixels, unsigned int width, unsigned int height, unsigned char bytes_per_pixel, bool amask0)
{
    FreeSurface(*this);

    switch(bytes_per_pixel)
    {
	case 1:
	    CreateSurface(width, height, 8, false);
	    LoadPalette();
	    Lock();
	    std::memcpy(surface->pixels, pixels, width * height);
	    Unlock();
	    break;

	default:
	{
	    u32 rmask, gmask, bmask, amask;
	    GetRGBAMask(bytes_per_pixel * 8, rmask, gmask, bmask, amask);
	    surface = SDL_CreateRGBSurfaceFrom(const_cast<void *>(pixels), width, height, 8 * bytes_per_pixel, width * bytes_per_pixel,
		rmask, gmask, bmask, (amask0 ? amask : 0));
	}
	break;
    }

    if(!surface)
	Error::Except(__FUNCTION__, SDL_GetError());
}
Example #8
0
/* bpp: 8, 16, 24, 32 */
void Surface::Set(u16 sw, u16 sh, u8 bpp, bool amask0)
{
    FreeSurface(*this);
    CreateSurface(sw, sh, bpp, amask0);

    if(8 == bpp) LoadPalette();
    SetDefaultColorKey();
}
Example #9
0
static void sub_810D028(u8 taskId)
{
    REG_DISPCNT = 0;
    LZ77UnCompVram(gCaveTransitionTiles, (void *)0x600C000);
    LZ77UnCompVram(gCaveTransitionTilemap, (void *)0x600F800);
    REG_BLDCNT = 0;
    REG_BLDALPHA = 0;
    REG_BLDY = 0;
    REG_BG0CNT = 7948;
    REG_DISPCNT = 4416;
    LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20);
    LoadPalette(gCaveTransitionPalette_Black, 0, 0x20);
    gTasks[taskId].func = sub_810D0C4;
    gTasks[taskId].data[0] = 16;
    gTasks[taskId].data[1] = 0;
    gTasks[taskId].data[2] = 0;
}
Example #10
0
static void Init() {
  uvmap = NewUVMap(WIDTH, HEIGHT, UV_FAST, 256, 256);
  canvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT);

  ChangeMap(0);

  InitDisplay(WIDTH, HEIGHT, DEPTH);
  LoadPalette(texturePal);
}
Example #11
0
static void sub_810CF5C(u8 taskId)
{
    u16 count;

    REG_BLDALPHA = 4112;

    count = gTasks[taskId].data[2];

    if (count < 8)
    {
        gTasks[taskId].data[2]++;
        LoadPalette(&gUnknown_083F809C[count], 0xE0, 16 - 2 * count);
    }
    else
    {
        LoadPalette(gCaveTransitionPalette_White, 0, 0x20);
        gTasks[taskId].func = sub_810CFC4;
        gTasks[taskId].data[2] = 8;
    }
}
Example #12
0
void task_a_8143D04(u8 taskIdA)
{
    switch (gMain.state)
    {
    default:
    case 0:
    {
        u16 i;

        ResetSpriteData();
        FreeAllSpritePalettes();
        gReservedSpritePaletteCount = 8;
        LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM);
        LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800));
        LoadPalette(gBirchBagGrassPal[0] + 1, 1, 31 * 2);

        for (i = 0; i < 0x800; i++)
            HALL_OF_FAME_SHEET_0[i] = 0x11;
        for (i = 0; i < 0x800; i++)
            HALL_OF_FAME_SHEET_1[i] = 0x22;
        for (i = 0; i < 0x800; i++)
            HALL_OF_FAME_SHEET_2[i] = 0x33;

        EWRAM_1F800[0] = 0;
        EWRAM_1F800[1] = 0x53FF; // light yellow
        EWRAM_1F800[2] = 0x529F; // light red
        EWRAM_1F800[3] = 0x7E94; // light blue

        LoadSpriteSheet(gUnknown_0840CAA0);
        LoadSpritePalette(gUnknown_0840CAB0);

        gMain.state += 1;
        break;
    }
    case 1:
        gTasks[taskIdA].data[TDA_TASK_D_ID] = CreateTask(task_d_8144514, 0);
        gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_STATE] = 1;
        gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_TASK_A_ID] = taskIdA;
        gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_2] = gTasks[taskIdA].data[TDA_7];

        BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0));
        REG_BG3HOFS = 0;
        REG_BG3VOFS = 32;
        REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256;
        REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON;

        gMain.state = 0;
        gUnknown_0203935C = 0;
        gTasks[taskIdA].func = task_a_8143B38;
        break;
    }
}
Example #13
0
static void Init() {
  canvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT);
  PixBufClear(canvas);

  uvmap = NewUVMap(WIDTH, HEIGHT, UV_NORMAL, 256, 256);
  UVMapSetTexture(uvmap, texture);

  shades = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);
  smallMap = NewUVMap(H_RAYS, V_RAYS, UV_ACCURATE, 256, 256);
  lightFunc = CalculateLightFunc();

  LoadPalette(texturePal);
  InitDisplay(WIDTH, HEIGHT, DEPTH);
}
Example #14
0
static void Load() {
  screen = NewBitmap(WIDTH, HEIGHT, DEPTH + 1);
  palette = LoadPalette("boxes-pal.ilbm");
  anim = LoadFile("running.bin", MEMF_PUBLIC);

  Log("Animation has %ld frames %ld x %ld.\n", 
      (LONG)anim->count, (LONG)anim->width, (LONG)anim->height);

  {
    WORD i;

    for (i = 0; i < anim->count; i++)
      anim->frame[i] = (APTR)anim->frame[i] + (LONG)anim;
  }
}
Example #15
0
static void sub_810D128(u8 taskId)
{
    u16 count = 16 - gTasks[taskId].data[1];
    u16 blend = count + 0x1000;
    REG_BLDALPHA = blend;
    if (count)
    {
        gTasks[taskId].data[1]++;
    }
    else
    {
        LoadPalette(gCaveTransitionPalette_Black, 0, 0x20);
        SetMainCallback2(gMain.savedCallback);
    }
}
Example #16
0
/*
 * Set up effect function.
 */
void SetupEffect() {
  UVMapT *uvmap = R_("Map");
  PixBufT *shades = R_("Shades");

  LoadPalette(R_("TexturePal"));

  UVMapGenerate4(uvmap);
  UVMapSetTexture(uvmap, R_("Texture"));
  uvmap->lightMap = shades;
  PixBufSetColorMap(shades, R_("ColorMap"));

  ResAdd("Component", NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.u));

  StartProfiling();
}
Example #17
0
static void sub_810D0C4(u8 taskId)
{
    u16 count = gTasks[taskId].data[2];
    if (count < 16)
    {
        gTasks[taskId].data[2]++;
        gTasks[taskId].data[2]++;
        LoadPalette(&gUnknown_083F808C[15 - count], 0xE0, 2 * (count + 1));
    }
    else
    {
        REG_BLDALPHA = 4112;
        REG_BLDCNT = 15937;
        gTasks[taskId].func = sub_810D128;
    }
}
Example #18
0
static void Init() {
  canvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT);

  shades = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);
  PixBufSetColorMap(shades, colorMap);

  uvmap = NewUVMap(WIDTH, HEIGHT, UV_FAST, 256, 256);
  uvmap->lightMap = shades;
  UVMapGenerate4(uvmap);
  UVMapSetTexture(uvmap, texture);

  component = NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.u);
  colorFunc = NewTable(uint8_t, 256);

  InitDisplay(WIDTH, HEIGHT, DEPTH);
  LoadPalette(texturePal);
}
Example #19
0
Image* LoadMDLImageBuff( byte* buffer ){
	if ( !LoadPalette() ) {
		return 0;
	}

	if ( !ident_equal( buffer, MDL_IDENT ) ) {
		globalErrorStream() << "LoadMDLImage: data has wrong ident\n";
		return 0;
	}

	PointerInputStream inputStream( buffer );
	inputStream.seek( 4 + 4 + 12 + 12 + 4 + 12 );
	//int numskins =
	istream_read_int32_le( inputStream );
	int skinwidth = istream_read_int32_le( inputStream );
	int skinheight = istream_read_int32_le( inputStream );
	inputStream.seek( 4 + 4 + 4 + 4 + 4 + 4 );

	switch ( istream_read_int32_le( inputStream ) )
	{
	case MDL_SKIN_SINGLE:
		break;
	case MDL_SKIN_GROUP:
		int numskins = istream_read_int32_le( inputStream );
		inputStream.seek( numskins * 4 );
		break;
	}

	RGBAImage* image = new RGBAImage( skinwidth, skinheight );
	unsigned char* pRGBA = image->getRGBAPixels();

	for ( int i = 0; i < ( skinheight ); i++ )
	{
		for ( int j = 0; j < ( skinwidth ); j++ )
		{
			byte index = istream_read_byte( inputStream );
			*pRGBA++ = mdl_palette[index * 3 + 0];
			*pRGBA++ = mdl_palette[index * 3 + 1];
			*pRGBA++ = mdl_palette[index * 3 + 2];
			*pRGBA++ = 255;
		}
	}

	return image;
}
Example #20
0
static void Load() {
  twister = LoadILBMCustom("twister.ilbm", BM_DISPLAYABLE);
  texture = LoadPNG("twister-texture.png", PM_RGB12, MEMF_PUBLIC);
  gradient = LoadPalette("twister-gradient.ilbm");

  {
    BitmapT *_left = LoadILBMCustom("twister-left.ilbm", 0);
    BitmapT *_right = LoadILBMCustom("twister-right.ilbm", 0);

    left[0] = NewSpriteFromBitmap(256, _left, 0, 0);
    left[1] = NewSpriteFromBitmap(256, _left, 16, 0);
    right[0] = NewSpriteFromBitmap(256, _right, 0, 0);
    right[1] = NewSpriteFromBitmap(256, _right, 16, 0);

    DeleteBitmap(_right);
    DeleteBitmap(_left);
  }
}
Example #21
0
static void Init() {
  canvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT);

  uvmap = NewUVMap(WIDTH, HEIGHT, UV_FAST, 256, 256);
  UVMapGenerate2(uvmap);
  UVMapSetTexture(uvmap, texture);

  orig = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);
  PixBufBlit(orig, 0, 0,
             NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.u), NULL);

  scene = NewScene();
  SceneAddObject(scene, NewSceneObject("Object", mesh));

  shades = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);

  InitDisplay(WIDTH, HEIGHT, DEPTH);
  LoadPalette(texturePal);
}
Example #22
0
static void PaletteEffect(FrameT *frame, PaletteT *src, PaletteT *dst) {
  bool beatFlash = CountBeat(frame);
  int j = 0;

  while (src) {
    int i;

    for (i = 0; i < src->count; i++) {
      RGB col = src->colors[i];

      int r = col.r;
      int g = col.g;
      int b = col.b;

      if (beatFlash) {
        r += 64; g += 64; b += 64;
      }

      {
        int f = frame->number;

        if (f >= 25)
          f = (frame->last - frame->first) - f;

        if (f < 25) {
          r = r * f / 25;
          g = g * f / 25;
          b = b * f / 25;
        }
      }

      dst->colors[j++] = MakeRGB(r, g, b);

      if (j >= 256)
        break;
    }

    src = src->next;
  }
  
  LoadPalette(dst);
}
Example #23
0
/*
 * Load demo.
 */
bool LoadDemo() {
  const char *loadImgPath = JsonQueryString(DemoConfig, "load/image");
  const char *loadPalPath = JsonQueryString(DemoConfig, "load/palette");
  const char *musicPath = JsonQueryString(DemoConfig, "music/file");

  if ((TheLoadImg = NewPixBufFromFile(loadImgPath)) &&
      (TheLoadPal = NewPaletteFromFile(loadPalPath)) &&
      (TheMusic = AudioStreamOpen(musicPath)) &&
      (TheCanvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT)) &&
      InitDisplay(WIDTH, HEIGHT, DEPTH))
  {
    c2p1x1_8_c5_bm(TheLoadImg->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
    LoadPalette(TheLoadPal);
    DisplaySwap();

    return true;
  }

  return false;
}
void YsColorPaletteDialog::OnModalDialogClosed(int,class FsGuiDialog *closedModalDialog,int modalDialogEndCode)
{
	if(closedModalDialog==fdlg && YSOK==fdlg->res && 0<fdlg->selectedFileArray.GetN())
	{
		if(fdlg->mode==FsGuiFileDialog::MODE_SAVE)
		{
			FILE *fp=YsFileIO::Fopen(fdlg->selectedFileArray[0],"rb");
			if(NULL!=fp)
			{
				fclose(fp);

				savePaletteFileName=fdlg->selectedFileArray[0];
				yesno.Initialize();
				yesno.Make(
				    L"File Already Exists.",
				    L"File Already Exists. Overwrite?",
				    L"Yes",
				    L"No",
				    (int)YSOK,
				    (int)YSERR);
				AttachModalDialog(&yesno);
			}
			else
			{
				SavePalette(fdlg->selectedFileArray[0]);
			}
		}
		else if(fdlg->mode==FsGuiFileDialog::MODE_OPEN)
		{
			LoadPalette(fdlg->selectedFileArray[0]);
			canvas->SetNeedRedraw(YSTRUE);
		}
	}
	else if(&yesno==closedModalDialog && modalDialogEndCode==(int)YSOK)
	{
		if(fdlg->mode==FsGuiFileDialog::MODE_SAVE)
		{
			SavePalette(fdlg->selectedFileArray[0]);
		}
	}
}
Example #25
0
/*
 * Set up effect function.
 */
void SetupEffect() {
  PaletteT *palette = R_("Palette");
  RGB *colors = palette->colors;
  int i;

  /* create a suitable fire palette, this is crucial for a good effect */
  /* black to blue, blue to red, red to yellow, yellow to white*/
  for (i = 0; i < 32; i++) {
    /* black to blue, 32 values*/
    colors[i].b = i << 1;

    /* blue to red, 32 values*/
    colors[i + 32].r = i << 3;
    colors[i + 32].b =  64 - (i << 1);

    /*red to yellow, 32 values*/
    colors[i + 64].r = 255;
    colors[i + 64].g = i << 3;

    /* yellow to white, 162 */
    colors[i + 96].r = 255;
    colors[i + 96].g = 255;
    colors[i + 96].b = i << 2;
    colors[i + 128].r = 255;
    colors[i + 128].g = 255;
    colors[i + 128].b = 64 + (i << 2);
    colors[i + 160].r = 255;
    colors[i + 160].g = 255;
    colors[i + 160].b = 128 + (i << 2);
    colors[i + 192].r = 255;
    colors[i + 192].g = 255;
    colors[i + 192].b = 192 + i;
    colors[i + 224].r = 255;
    colors[i + 224].g = 255;
    colors[i + 224].b = 224 + i;
  } 

  LoadPalette(palette);
  StartProfiling();
}
Example #26
0
static void Init() {
  canvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT);
  map[0] = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);
  map[1] = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);
  shade = NewPixBuf(PIXBUF_GRAY, WIDTH, HEIGHT);

  {
    FLineT line;
    FPointT pa = { 0, 0 };
    FPointT pb = { WIDTH, HEIGHT };

    FLineInitFromPoints(&line, &pa, &pb);
    LinearGradient(map[0], &line);
  }

  {
    FPointT center = { WIDTH / 2, HEIGHT / 2 };
    CircularGradient(map[1], &center);
  }

  InitDisplay(WIDTH, HEIGHT, DEPTH);
  LoadPalette(imagePal);
}
Example #27
0
int CPDF_DIBSource::ContinueToLoadMask() {
  if (m_bImageMask) {
    m_bpp = 1;
    m_bpc = 1;
    m_nComponents = 1;
    m_AlphaFlag = 1;
  } else if (m_bpc * m_nComponents == 1) {
    m_bpp = 1;
  } else if (m_bpc * m_nComponents <= 8) {
    m_bpp = 8;
  } else {
    m_bpp = 24;
  }
  if (!m_bpc || !m_nComponents) {
    return 0;
  }
  FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width);
  if (!pitch.IsValid()) {
    return 0;
  }
  m_pLineBuf = FX_Alloc(uint8_t, pitch.ValueOrDie());
  if (m_pColorSpace && m_bStdCS) {
    m_pColorSpace->EnableStdConversion(true);
  }
  LoadPalette();
  if (m_bColorKey) {
    m_bpp = 32;
    m_AlphaFlag = 2;
    pitch = CalculatePitch32(m_bpp, m_Width);
    if (!pitch.IsValid()) {
      return 0;
    }
    m_pMaskedLine = FX_Alloc(uint8_t, pitch.ValueOrDie());
  }
  m_Pitch = pitch.ValueOrDie();
  return 1;
}
Example #28
0
bool CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream) {
  if (!pStream)
    return false;

  m_pDocument = pDoc;
  m_pDict = pStream->GetDict();
  if (!m_pDict)
    return false;

  m_pStream = pStream;
  m_Width = m_pDict->GetIntegerFor("Width");
  m_Height = m_pDict->GetIntegerFor("Height");
  if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension ||
      m_Height > kMaxImageDimension) {
    return false;
  }
  m_GroupFamily = 0;
  m_bLoadMask = false;
  if (!LoadColorInfo(nullptr, nullptr))
    return false;

  if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0))
    return false;

  FX_SAFE_UINT32 src_size =
      CalculatePitch8(m_bpc, m_nComponents, m_Width) * m_Height;
  if (!src_size.IsValid())
    return false;

  m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
  m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
  if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData())
    return false;

  if (!CreateDecoder())
    return false;

  if (m_bImageMask) {
    m_bpp = 1;
    m_bpc = 1;
    m_nComponents = 1;
    m_AlphaFlag = 1;
  } else if (m_bpc * m_nComponents == 1) {
    m_bpp = 1;
  } else if (m_bpc * m_nComponents <= 8) {
    m_bpp = 8;
  } else {
    m_bpp = 24;
  }
  FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width);
  if (!pitch.IsValid())
    return false;

  m_pLineBuf = FX_Alloc(uint8_t, pitch.ValueOrDie());
  LoadPalette();
  if (m_bColorKey) {
    m_bpp = 32;
    m_AlphaFlag = 2;
    pitch = CalculatePitch32(m_bpp, m_Width);
    if (!pitch.IsValid())
      return false;

    m_pMaskedLine = FX_Alloc(uint8_t, pitch.ValueOrDie());
  }
  m_Pitch = pitch.ValueOrDie();
  return true;
}
Example #29
0
/*
 * Set up effect function.
 */
void SetupEffect() {
  PixBufClear(R_("Canvas"));
  LoadPalette(R_("Palette"));
  StartProfiling();
}
Example #30
0
 Palette256(char *p)
 {  InitGraph();
    LoadPalette(p);
    SetHardPalette();
 };