LPBYTE ExeIconReplacer::CreateIconGroupData(int nBaseID) { delete m_group; m_group = new BYTE[SizeOfIconGroupData()]; CopyMemory(m_group, &m_dir, sizeof(ICONDIR)); int offset = sizeof(ICONDIR); for (int i = 0; i < GetImageCount(); i++) { BITMAPINFOHEADER bmih; CopyMemory(&bmih, GetImageData(i), sizeof(BITMAPINFOHEADER)); GRPICONDIRENTRY grpEntry; grpEntry.bWidth = m_entry[i].bWidth; grpEntry.bHeight = m_entry[i].bHeight; grpEntry.bColorCount = m_entry[i].bColorCount; grpEntry.bReserved = m_entry[i].bReserved; grpEntry.wPlanes = bmih.biPlanes; grpEntry.wBitCount = bmih.biBitCount; grpEntry.dwBytesInRes = m_entry[i].dwBytesInRes; grpEntry.nID = nBaseID + i; CopyMemory(m_group + offset, &grpEntry, sizeof(GRPICONDIRENTRY)); offset += sizeof(GRPICONDIRENTRY); } return m_group; } // ExeIconReplacer::CreateIconGroupData
WebPMuxError WebPMuxSetImage(WebPMux* mux, const WebPData* bitstream, int copy_data) { WebPMuxError err; WebPChunk chunk; WebPMuxImage wpi; WebPData image; WebPData alpha; int is_lossless; int image_tag; if (mux == NULL || bitstream == NULL || bitstream->bytes_ == NULL || bitstream->size_ > MAX_CHUNK_PAYLOAD) { return WEBP_MUX_INVALID_ARGUMENT; } // If given data is for a whole webp file, // extract only the VP8/VP8L data from it. err = GetImageData(bitstream, &image, &alpha, &is_lossless); if (err != WEBP_MUX_OK) return err; image_tag = is_lossless ? kChunks[IDX_VP8L].tag : kChunks[IDX_VP8].tag; // Delete the existing images. MuxImageDeleteAll(&mux->images_); MuxImageInit(&wpi); if (alpha.bytes_ != NULL) { // Add alpha chunk. ChunkInit(&chunk); err = ChunkAssignData(&chunk, &alpha, copy_data, kChunks[IDX_ALPHA].tag); if (err != WEBP_MUX_OK) goto Err; err = ChunkSetNth(&chunk, &wpi.alpha_, 1); if (err != WEBP_MUX_OK) goto Err; } // Add image chunk. ChunkInit(&chunk); err = ChunkAssignData(&chunk, &image, copy_data, image_tag); if (err != WEBP_MUX_OK) goto Err; err = ChunkSetNth(&chunk, &wpi.img_, 1); if (err != WEBP_MUX_OK) goto Err; // Add this image to mux. err = MuxImagePush(&wpi, &mux->images_); if (err != WEBP_MUX_OK) goto Err; // All OK. return WEBP_MUX_OK; Err: // Something bad happened. ChunkRelease(&chunk); MuxImageRelease(&wpi); return err; }
/** * creates a char samp from a specified portion of the image */ CharSamp *CubeUtils::CharSampleFromPix(Pix *pix, int left, int top, int wid, int hgt) { // get the raw img data from the image unsigned char *temp_buff = GetImageData(pix, left, top, wid, hgt); if (temp_buff == NULL) { return NULL; } // create a char samp from temp buffer CharSamp *char_samp = CharSamp::FromRawData(left, top, wid, hgt, temp_buff); // clean up temp buffer delete[]temp_buff; return char_samp; }
// Extracts image & alpha data from the given bitstream and then sets wpi.alpha_ // and wpi.img_ appropriately. static WebPMuxError SetAlphaAndImageChunks( const WebPData* const bitstream, int copy_data, WebPMuxImage* const wpi) { int is_lossless = 0; WebPData image, alpha; WebPMuxError err = GetImageData(bitstream, &image, &alpha, &is_lossless); const int image_tag = is_lossless ? kChunks[IDX_VP8L].tag : kChunks[IDX_VP8].tag; if (err != WEBP_MUX_OK) return err; if (alpha.bytes != NULL) { err = AddDataToChunkList(&alpha, copy_data, kChunks[IDX_ALPHA].tag, &wpi->alpha_); if (err != WEBP_MUX_OK) return err; } return AddDataToChunkList(&image, copy_data, image_tag, &wpi->img_); }
void ThemeMenu::AddMainButtons() { HaltGui(); for(u32 i = 0; i < MainButton.size(); ++i) Remove(MainButton[i]); int FirstItem = currentPage*4; int n = 0; for(int i = FirstItem; i < (int) MainButton.size() && i < FirstItem+4; ++i) { delete ThemePreviews[n]; ThemePreviews[n] = GetImageData(i); MainButtonImgOver[i]->SetImage(ThemePreviews[n]); n++; } FlyingButtonsMenu::AddMainButtons(); }
void Scale16::scale(unsigned short *dest, int destWidth, int destHeight, int destStride, unsigned short const *img, int imgWidth, int imgHeight, int picLeft, int picTop, int picWidth,int picHeight) { ImageData* pImageData = GetImageData(img,imgWidth,imgHeight); if (pImageData) { Scale* pScale = new ScaleRGB(pImageData); //give my reference to pImageData if successful if (pScale) { BYTE* dib = pScale->GetDibBits(destWidth,destHeight,0,0, destWidth,destHeight, picLeft,picTop,picWidth,picHeight, NULL,0); if (dib) { render(dest,destWidth,destHeight,destStride,0,0, dib,destWidth,destHeight, 0,0,destWidth,destHeight); delete [] dib; } pScale->Release(); } else pImageData->Release(); } }
bool VaultImageNode::ExtractImage (plMipmap ** dst) { hsRAMStream ramStream; ramStream.Write(GetImageDataLength(), GetImageData()); ramStream.Rewind(); switch (GetImageType()) { case kJPEG: (*dst) = plJPEG::Instance().ReadFromStream(&ramStream); break; case kPNG: (*dst) = plPNG::Instance().ReadFromStream(&ramStream); break; case kNone: default: (*dst) = nil; break; } return ((*dst) != nil); }
bool CApnCamera::BufferImage(char *bufferName ) { unsigned short *pImageData; bool status; short cols,rows,hbin,vbin; unsigned short xSize, ySize; unsigned long count; cols = m_pvtExposurePixelsH; rows = m_pvtExposurePixelsV; /* ALTA code has already applied binning calculations*/ hbin = 1; vbin = 1; pImageData = (unsigned short *)CCD_locate_buffer(bufferName, 2 , cols, rows, hbin, vbin ); if (pImageData == NULL) { return 0; } status = GetImageData(pImageData, xSize, ySize, count); return status; }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) Image image = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM) ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) <-- ISSUE Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) int currentProcess = NONE; bool textureReload = false; Rectangle selectRecs[NUM_PROCESSES]; for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40, 50 + 32*i, 150, 30 }; SetTargetFPS(60); //--------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- if (IsKeyPressed(KEY_DOWN)) { currentProcess++; if (currentProcess > 7) currentProcess = 0; textureReload = true; } else if (IsKeyPressed(KEY_UP)) { currentProcess--; if (currentProcess < 0) currentProcess = 7; textureReload = true; } if (textureReload) { UnloadImage(image); // Unload current image data image = LoadImage("resources/parrots.png"); // Re-load image data // NOTE: Image processing is a costly CPU process to be done every frame, // If image processing is required in a frame-basis, it should be done // with a texture and by shaders switch (currentProcess) { case COLOR_GRAYSCALE: ImageColorGrayscale(&image); break; case COLOR_TINT: ImageColorTint(&image, GREEN); break; case COLOR_INVERT: ImageColorInvert(&image); break; case COLOR_CONTRAST: ImageColorContrast(&image, -40); break; case COLOR_BRIGHTNESS: ImageColorBrightness(&image, -80); break; case FLIP_VERTICAL: ImageFlipVertical(&image); break; case FLIP_HORIZONTAL: ImageFlipHorizontal(&image); break; default: break; } Color *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit) UpdateTexture(texture, pixels); // Update texture with new image data free(pixels); // Unload pixels data from RAM textureReload = false; } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY); // Draw rectangles for (int i = 0; i < NUM_PROCESSES; i++) { DrawRectangleRec(selectRecs[i], (i == currentProcess) ? SKYBLUE : LIGHTGRAY); DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, (i == currentProcess) ? BLUE : GRAY); DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, (i == currentProcess) ? DARKBLUE : DARKGRAY); } DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE); DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadTexture(texture); // Unload texture from VRAM UnloadImage(image); // Unload image from RAM CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
int main(int argc, char **argv) { u32 cookie; FILE *exeFile = NULL; void *exeBuffer = (void *)EXECUTABLE_MEM_ADDR; u32 exeSize = 0; u32 exeEntryPointAddress = 0; entrypoint exeEntryPoint; __exception_setreload(0); IOS_ReloadIOS(58); /* int videomod */ InitVideo(); /* get imagedata */ u8 * imgdata = GetImageData(); fadein(imgdata); /* check devices */ SDCard_Init(); USBDevice_Init(); char cfgpath[256]; bool result = false; sprintf(cfgpath, "sd:/config/SaveGame_Manager_GX/SaveGame_Manager_GX.cfg"); result = cfg_parsefile(cfgpath, &cfg_set); if(!result) //no cfg-File on SD: try USB: { sprintf(cfgpath, "usb:config/SaveGame_Manager_GX/SaveGame_Manager_GX.cfg"); result = cfg_parsefile(cfgpath, &cfg_set); } if(result) { sprintf(cfgpath, "%sboot.dol", update_path); /* Open dol File and check exist */ exeFile = fopen (cfgpath, "rb"); if (exeFile==NULL) { sprintf(cfgpath, "%sboot.elf", update_path); exeFile = fopen (cfgpath,"rb"); } if (exeFile==NULL) result = false; else result = true; } if(!result) // non cfg-File loaded or update_path not set { /* Open dol File and check exist */ sprintf(cfgpath, "sd:/apps/SaveGame_Manager_GX/boot.dol"); exeFile = fopen (cfgpath ,"rb"); if (exeFile==NULL) { sprintf(cfgpath, "sd:/apps/SaveGame_Manager_GX/boot.elf"); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, "usb:/apps/SaveGame_Manager_GX/boot.dol"); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, "usb:/apps/SaveGame_Manager_GX/boot.elf"); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, "sd:/apps/SaveGameManagerGX/boot.dol"); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, "sd:/apps/SaveGameManagerGX/boot.elf"); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, "usb:/apps/SaveGameManagerGX/boot.dol"); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, "usb:/apps/SaveGameManagerGX/boot.elf"); exeFile = fopen (cfgpath ,"rb"); } // if nothing found exiting if (exeFile==NULL) { fadeout(imgdata); fclose (exeFile); SDCard_deInit(); USBDevice_deInit(); StopGX(); free(imgdata); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } } fseek (exeFile, 0, SEEK_END); exeSize = ftell(exeFile); rewind (exeFile); if(fread (exeBuffer, 1, exeSize, exeFile) != exeSize) { fadeout(imgdata); fclose (exeFile); SDCard_deInit(); USBDevice_deInit(); StopGX(); free(imgdata); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } fclose (exeFile); /* load entry point */ struct __argv args; bzero(&args, sizeof(args)); args.argvMagic = ARGV_MAGIC; args.length = strlen(cfgpath) + 2; args.commandLine = (char*)malloc(args.length); if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); strcpy(args.commandLine, cfgpath); args.commandLine[args.length - 1] = '\0'; args.argc = 1; args.argv = &args.commandLine; args.endARGV = args.argv + 1; u8 * appboot_buff = (u8 *) malloc(app_booter_dol_size); if(!appboot_buff) { fadeout(imgdata); SDCard_deInit(); USBDevice_deInit(); StopGX(); free(imgdata); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } memcpy(appboot_buff, app_booter_dol, app_booter_dol_size); exeEntryPointAddress = load_dol_image(appboot_buff, &args); if(appboot_buff) free(appboot_buff); fadeout(imgdata); SDCard_deInit(); USBDevice_deInit(); StopGX(); free(imgdata); if (exeEntryPointAddress == 0) { SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } exeEntryPoint = (entrypoint) exeEntryPointAddress; /* cleaning up and load dol */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cookie); __exception_closeall (); exeEntryPoint (); _CPU_ISR_Restore (cookie); return 0; }
Void CodeMB(Vop *curr, Vop *rec_curr, Vop *comp, Int x_pos, Int y_pos, UInt width, Int QP, Int Mode, Int *qcoeff) { Int k; Int fblock[6][8][8]; Int coeff[384]; Int *coeff_ind; Int *qcoeff_ind; Int* rcoeff_ind; Int x, y; SInt *current, *recon, *compensated = NULL; UInt xwidth; Int iblock[6][8][8]; Int rcoeff[6*64]; Int i, j; Int type; /* luma = 1, chroma = 2 */ // Int *qmat; SInt tmp[64]; Int s; int operation = curr->prediction_type; /* This variable is for combined operation. If it is an I_VOP, then MB in curr is reconstruct into rec_curr, and comp is not used at all (i.e., it can be set to NULL). If it is a P_VOP, then MB in curr is reconstructed, and the result added with MB_comp is written into rec_curr. - adamli 11/19/2000 */ Int max = GetVopBrightWhite(curr); /* This variable is the max value for the clipping of the reconstructed image. */ coeff_ind = coeff; qcoeff_ind = qcoeff; rcoeff_ind = rcoeff; for (k = 0; k < 6; k++) { switch (k) { case 0: x = x_pos; y = y_pos; xwidth = width; current = (SInt *) GetImageData (GetVopY (curr)); break; case 1: x = x_pos + 8; y = y_pos; xwidth = width; current = (SInt *) GetImageData (GetVopY (curr)); break; case 2: x = x_pos; y = y_pos + 8; xwidth = width; current = (SInt *) GetImageData (GetVopY (curr)); break; case 3: x = x_pos + 8; y = y_pos + 8; xwidth = width; current = (SInt *) GetImageData (GetVopY (curr)); break; case 4: x = x_pos / 2; y = y_pos / 2; xwidth = width / 2; current = (SInt *) GetImageData (GetVopU (curr)); break; case 5: x = x_pos / 2; y = y_pos / 2; xwidth = width / 2; current = (SInt *) GetImageData (GetVopV (curr)); break; default: break; } BlockPredict (current, x, y, xwidth, fblock[k]); } for (k = 0; k < 6; k++) { s = 0; for (i = 0; i < 8; i++) for (j = 0; j < 8; j++) tmp[s++] = (SInt) fblock[k][i][j]; #ifndef _MMX_ fdct_enc(tmp); #else fdct_mm32(tmp); #endif for (s = 0; s < 64; s++) coeff_ind[s] = (Int) tmp[s]; if (k < 4) type = 1; else type = 2; /* For this release, only H263 quantization is supported. - adamli */ BlockQuantH263(coeff_ind,QP,Mode,type,qcoeff_ind, GetVopBrightWhite(curr),1); BlockDequantH263(qcoeff_ind,QP,Mode,type,rcoeff_ind,1, 0, GetVopBitsPerPixel(curr)); for (s = 0; s < 64; s++) tmp[s] = (SInt) rcoeff_ind[s]; #ifndef _MMX_ idct_enc(tmp); #else Fast_IDCT(tmp); #endif s = 0; for (i = 0; i < 8; i++) for (j = 0; j < 8; j++) iblock[k][i][j] = (Int)tmp[s++]; coeff_ind += 64; qcoeff_ind += 64; rcoeff_ind += 64; if (Mode == MODE_INTRA||Mode==MODE_INTRA_Q) for (i = 0; i < 8; i++) for (j = 0; j < 8; j ++) iblock[k][i][j] = MIN (GetVopBrightWhite(curr), MAX (0, iblock[k][i][j])); switch (k) { case 0: case 1: case 2: continue; case 3: recon = (SInt *) GetImageData (GetVopY (rec_curr)); if (operation == P_VOP) compensated = (SInt *) GetImageData (GetVopY (comp)); BlockRebuild (recon, compensated, operation, max, x_pos, y_pos, width, 16, iblock[0]); BlockRebuild (recon, compensated, operation, max, x_pos + 8, y_pos, width, 16, iblock[1]); BlockRebuild (recon, compensated, operation, max, x_pos, y_pos + 8, width, 16, iblock[2]); BlockRebuild (recon, compensated, operation, max, x_pos + 8, y_pos + 8, width, 16, iblock[3]); continue; case 4: recon = (SInt *) GetImageData (GetVopU (rec_curr)); if (operation == P_VOP) compensated = (SInt *) GetImageData (GetVopU (comp)); BlockRebuild (recon, compensated, operation, max, x_pos/2, y_pos/2, width/2, 8, iblock[4]); continue; case 5: recon = (SInt *) GetImageData (GetVopV (rec_curr)); if (operation == P_VOP) compensated = (SInt *) GetImageData (GetVopV (comp)); BlockRebuild (recon, compensated, operation, max, x_pos/2, y_pos/2, width/2, 8, iblock[5]); continue; } } return; }
int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze"); // Define the camera to look into our 3d world Camera camera = { { 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM) Mesh mesh = GenMeshCubicmap(imMap, (Vector3){ 1.0f, 1.0f, 1.0f }); Model model = LoadModelFromMesh(mesh); // NOTE: By default each cube is mapped to one part of texture atlas Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture // Get map image data to be used for collision detection Color *mapPixels = GetImageData(imMap); UnloadImage(imMap); // Unload image from RAM Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position Vector3 playerPosition = camera.position; // Set player position SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set camera mode SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- Vector3 oldCamPos = camera.position; // Store old camera position UpdateCamera(&camera); // Update camera // Check player collision (we simplify to 2D collision detection) Vector2 playerPos = { camera.position.x, camera.position.z }; float playerRadius = 0.1f; // Collision radius (player is modelled as a cilinder for collision) int playerCellX = (int)(playerPos.x - mapPosition.x + 0.5f); int playerCellY = (int)(playerPos.y - mapPosition.z + 0.5f); // Out-of-limits security check if (playerCellX < 0) playerCellX = 0; else if (playerCellX >= cubicmap.width) playerCellX = cubicmap.width - 1; if (playerCellY < 0) playerCellY = 0; else if (playerCellY >= cubicmap.height) playerCellY = cubicmap.height - 1; // Check map collisions using image data and player position // TODO: Improvement: Just check player surrounding cells for collision for (int y = 0; y < cubicmap.height; y++) { for (int x = 0; x < cubicmap.width; x++) { if ((mapPixels[y*cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel (CheckCollisionCircleRec(playerPos, playerRadius, (Rectangle){ mapPosition.x - 0.5f + x*1.0f, mapPosition.z - 0.5f + y*1.0f, 1.0f, 1.0f }))) { // Collision detected, reset camera position camera.position = oldCamPos; } } } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); BeginMode3D(camera); DrawModel(model, mapPosition, 1.0f, WHITE); // Draw maze map //DrawCubeV(playerPosition, (Vector3){ 0.2f, 0.4f, 0.2f }, RED); // Draw player EndMode3D(); DrawTextureEx(cubicmap, (Vector2){ GetScreenWidth() - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE); DrawRectangleLines(GetScreenWidth() - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); // Draw player position radar DrawRectangle(GetScreenWidth() - cubicmap.width*4 - 20 + playerCellX*4, 20 + playerCellY*4, 4, 4, RED); DrawFPS(10, 10); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- free(mapPixels); // Unload color array UnloadTexture(cubicmap); // Unload cubicmap texture UnloadTexture(texture); // Unload map texture UnloadModel(model); // Unload map model CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
int InitDecodeNotifyEvent(XParms xp, Parms p, int reps) { XIEimage *image; XieDecodeUncompressedSingleParam *decode_params=NULL; XieEncodeTechnique encode_tech=xieValEncodeServerChoice; char *encode_params=NULL; XieLTriplet width, height, levels; XIEPhotomap = ( XiePhotomap ) NULL; XIEPhotomap2 = ( XiePhotomap ) NULL; flograph = ( XiePhotoElement * ) NULL; flo = ( XiePhotoflo ) NULL; image = p->finfo.image1; if ( !GetImageData( xp, p, 1 ) ) reps = 0; else { if ( !image ) reps = 0; else { size = image->fsize; width[ 0 ] = image->width[ 0 ]; height[ 0 ] = image->height[ 0 ]; levels[ 0 ] = image->levels[ 0 ]; } } if ( reps ) { XIEPhotomap = XieCreatePhotomap(xp->d); XIEPhotomap2 = XieCreatePhotomap(xp->d); decode_params = XieTecDecodeUncompressedSingle( image->fill_order, image->pixel_order, image->pixel_stride[ 0 ], image->left_pad[ 0 ], image->scanline_pad[ 0 ] ); flo_elements = 2; flograph = XieAllocatePhotofloGraph(flo_elements); if ( flograph == ( XiePhotoElement * ) NULL ) { reps = 0; } } if ( reps ) { XieFloImportClientPhoto(&flograph[0], image->bandclass, width, height, levels, True, image->decode, (char *)decode_params ); XieFloExportPhotomap(&flograph[1], 1, /* source phototag number */ XIEPhotomap2, encode_tech, encode_params ); flo = XieCreatePhotoflo( xp->d, flograph, flo_elements ); } if ( !reps ) FreeDecodeNotifyEventStuff( xp, p ); if ( decode_params ) XFree( decode_params ); return reps; }
//---------------------------------------------------------------------------------- // Main entry point //---------------------------------------------------------------------------------- int main(void) { // Initialization //--------------------------------------------------------- InitWindow(screenWidth, screenHeight, "GGJ16 - LIGHT MY RITUAL!"); // Global data loading (assets that must be available in all screens, i.e. fonts) InitAudioDevice(); Image image = LoadImage("resources/lights_map.png"); // Load image in CPU memory (RAM) lightsMap = GetImageData(image); // Get image pixels data as an array of Color lightsMapWidth = image.width; lightsMapHeight = image.height; UnloadImage(image); // Unload image from CPU memory (RAM) //PlayMusicStream("resources/audio/come_play_with_me.ogg"); font = LoadSpriteFont("resources/font_arcadian.png"); //doors = LoadTexture("resources/textures/doors.png"); //sndDoor = LoadSound("resources/audio/door.ogg"); // Setup and Init first screen currentScreen = LOGO_RL; //InitTitleScreen(); //InitGameplayScreen(); rlInitLogoScreen(); #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); #else SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { UpdateDrawFrame(); } #endif // De-Initialization //-------------------------------------------------------------------------------------- switch (currentScreen) { case LOGO_RL: rlUnloadLogoScreen(); break; case TITLE: UnloadTitleScreen(); break; case GAMEPLAY: UnloadGameplayScreen(); break; default: break; } // Unload all global loaded data (i.e. fonts) here! UnloadSpriteFont(font); //UnloadSound(sndDoor); free(lightsMap); CloseAudioDevice(); CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
// Gameplay Screen Initialization logic void InitGameplayScreen(void) { // TODO: Initialize GAMEPLAY screen variables here! framesCounter = 0; finishScreen = 0; // MAP LAODING // TODO: Read .bmp file propierly in order to get image width & height Color *mapPixels = malloc(GRID_WIDTH*GRID_HEIGHT * sizeof(Color)); mapPixels = GetImageData(LoadImage("assets/gameplay_screen/maps/map.bmp")); maxTriangles = 0; maxPlatforms = 0; for (int i=0; i<GRID_WIDTH*GRID_HEIGHT; i++) { /* printf("r: %i\n", mapPixels[i].r); printf("g: %i\n", mapPixels[i].g); printf("b: %i\n\n", mapPixels[i].b); */ if (mapPixels[i].r == 255 && mapPixels[i].g == 0 && mapPixels[i].b == 0) maxTriangles++; else if (mapPixels[i].r == 0 && mapPixels[i].g == 255 && mapPixels[i].b == 0) maxPlatforms++; } triangles = malloc(maxTriangles * sizeof(TriangleObject)); platforms = malloc(maxPlatforms * sizeof(SquareObject)); int trianglesCounter=0; int platformsCounter=0; for (int y=0; y<GRID_HEIGHT; y++) { for (int x=0; x<GRID_WIDTH; x++) { if (mapPixels[y*GRID_WIDTH+x].r == 255 && mapPixels[y*GRID_WIDTH+x].g == 0 && mapPixels[y*GRID_WIDTH+x].b == 0) { InitializeTriangle(&triangles[trianglesCounter], (Vector2){x, y}); trianglesCounter++; } else if (mapPixels[y*GRID_WIDTH+x].r == 0 && mapPixels[y*GRID_WIDTH+x].g == 255 && mapPixels[y*GRID_WIDTH+x].b == 0) { InitializePlatform(&platforms[platformsCounter], (Vector2){x, y}); platformsCounter++; } } } free(mapPixels); //DEBUGGING && TESTING variables pause = FALSE; srand(time(NULL)); // Textures loading player.texture = LoadTexture("assets/gameplay_screen/cube_main.png"); triangleTexture = LoadTexture("assets/gameplay_screen/triangle_main.png"); platformTexture = LoadTexture("assets/gameplay_screen/platform_main.png"); player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png"); bg = LoadTexture("assets/gameplay_screen/bg_main.png"); // Sound loading InitAudioDevice(); PlayMusicStream("assets/gameplay_screen/music/Flash_Funk_MarshmelloRemix.ogg"); PauseMusicStream(); SetMusicVolume(0.5f); // Did player win? startGame = FALSE; /* player.texture = LoadTexture("assets/gameplay_screen/debug.png"); triangleTexture = LoadTexture("assets/gameplay_screen/debug.png"); platformTexture = LoadTexture("assets/gameplay_screen/debug.png"); player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png"); */ // Camera initialization mainCamera = (Camera2D){Vector2Right(), (Vector2){6.5f, 6.5f}, Vector2Zero(), TRUE}; // Gravity initialization gravity = (GravityForce){Vector2Up(), 1.5f}; // Ground position and coordinate groundCoordinadeY = GetScreenHeight()/CELL_SIZE-1; groundPositionY = GetOnGridPosition((Vector2){0, groundCoordinadeY}).y; // Player initialization InitializePlayer(&player, (Vector2){4, groundCoordinadeY-1}, (Vector2){0, 15}, 0.35f*GAME_SPEED); /* // Triangles initialization InitializeTriangle(&triangles[0], (Vector2){40, groundCoordinadeY-1}); InitializeTriangle(&triangles[1], (Vector2){50, groundCoordinadeY-1}); InitializeTriangle(&triangles[2], (Vector2){85, groundCoordinadeY-1}); // Platforms initialization InitializePlatform(&platforms[0], (Vector2){20, groundCoordinadeY-1}); InitializePlatform(&platforms[1], (Vector2){21, groundCoordinadeY-1}); InitializePlatform(&platforms[2], (Vector2){22, groundCoordinadeY-1}); InitializePlatform(&platforms[3], (Vector2){23, groundCoordinadeY-2}); InitializePlatform(&platforms[4], (Vector2){24, groundCoordinadeY-2}); */ }
static WebPMuxError MuxPushFrameTileInternal( WebPMux* const mux, const WebPData* const bitstream, int x_offset, int y_offset, int duration, int copy_data, uint32_t tag) { WebPChunk chunk; WebPData image; WebPData alpha; WebPMuxImage wpi; WebPMuxError err; WebPData frame_tile; const int is_frame = (tag == kChunks[IDX_FRAME].tag) ? 1 : 0; int is_lossless; int image_tag; // Sanity checks. if (mux == NULL || bitstream == NULL || bitstream->bytes_ == NULL || bitstream->size_ > MAX_CHUNK_PAYLOAD) { return WEBP_MUX_INVALID_ARGUMENT; } if (x_offset < 0 || x_offset >= MAX_POSITION_OFFSET || y_offset < 0 || y_offset >= MAX_POSITION_OFFSET || duration <= 0 || duration > MAX_DURATION) { return WEBP_MUX_INVALID_ARGUMENT; } // Snap offsets to even positions. x_offset &= ~1; y_offset &= ~1; // If given data is for a whole webp file, // extract only the VP8/VP8L data from it. err = GetImageData(bitstream, &image, &alpha, &is_lossless); if (err != WEBP_MUX_OK) return err; image_tag = is_lossless ? kChunks[IDX_VP8L].tag : kChunks[IDX_VP8].tag; WebPDataInit(&frame_tile); ChunkInit(&chunk); MuxImageInit(&wpi); if (alpha.bytes_ != NULL) { // Add alpha chunk. err = ChunkAssignData(&chunk, &alpha, copy_data, kChunks[IDX_ALPHA].tag); if (err != WEBP_MUX_OK) goto Err; err = ChunkSetNth(&chunk, &wpi.alpha_, 1); if (err != WEBP_MUX_OK) goto Err; ChunkInit(&chunk); // chunk owned by wpi.alpha_ now. } // Add image chunk. err = ChunkAssignData(&chunk, &image, copy_data, image_tag); if (err != WEBP_MUX_OK) goto Err; err = ChunkSetNth(&chunk, &wpi.img_, 1); if (err != WEBP_MUX_OK) goto Err; ChunkInit(&chunk); // chunk owned by wpi.img_ now. // Create frame/tile data. err = CreateFrameTileData(&image, x_offset, y_offset, duration, is_lossless, is_frame, &frame_tile); if (err != WEBP_MUX_OK) goto Err; // Add frame/tile chunk (with copy_data = 1). err = ChunkAssignData(&chunk, &frame_tile, 1, tag); if (err != WEBP_MUX_OK) goto Err; WebPDataClear(&frame_tile); err = ChunkSetNth(&chunk, &wpi.header_, 1); if (err != WEBP_MUX_OK) goto Err; ChunkInit(&chunk); // chunk owned by wpi.header_ now. // Add this WebPMuxImage to mux. err = MuxImagePush(&wpi, &mux->images_); if (err != WEBP_MUX_OK) goto Err; // All is well. return WEBP_MUX_OK; Err: // Something bad happened. WebPDataClear(&frame_tile); ChunkRelease(&chunk); MuxImageRelease(&wpi); return err; }
int main(int argc, char **argv) { u32 cookie; FILE *exeFile = NULL; void *exeBuffer = (void *)EXECUTABLE_MEM_ADDR; int exeSize = 0; u32 exeEntryPointAddress = 0; entrypoint exeEntryPoint; /* int videomod */ InitVideo(); /* get imagedata */ u8 * imgdata = GetImageData(); /* fadein of image */ for(int i = 0; i < 255; i = i+10) { if(i>255) i = 255; Background_Show(0, 0, 0, imgdata, 0, 1, 1, i); Menu_Render(); } /* check devices */ SDCard_Init(); USBDevice_Init(); char cfgpath[256]; /* Open dol File and check exist */ sprintf(cfgpath, PATH1); exeFile = fopen (cfgpath ,"rb"); if (exeFile==NULL) { sprintf(cfgpath, PATH2); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH3); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH4); exeFile = fopen (cfgpath ,"rb"); } if (PACK2) { if (exeFile==NULL) { sprintf(cfgpath, PATH5); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH6); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH7); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH8); exeFile = fopen (cfgpath ,"rb"); } } if (PACK3) { if (exeFile==NULL) { sprintf(cfgpath, PATH9); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH10); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH11); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH12); exeFile = fopen (cfgpath ,"rb"); } } if (PACK4) { if (exeFile==NULL) { sprintf(cfgpath, PATH13); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH14); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH15); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH16); exeFile = fopen (cfgpath ,"rb"); } } // if nothing found exiting if (exeFile==NULL) { printf("\n\n\t\tCan't find DOL File...\n"); Menu_Render(); sleep(3); fclose (exeFile); SDCard_deInit(); USBDevice_deInit(); StopGX(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } fseek (exeFile, 0, SEEK_END); exeSize = ftell(exeFile); fseek (exeFile, 0, SEEK_SET); if(fread (exeBuffer, 1, exeSize, exeFile) != (unsigned int) exeSize) { printf("\n\n\t\tCan't open DOL File...\n"); Menu_Render(); fclose (exeFile); sleep(3); SDCard_deInit(); USBDevice_deInit(); StopGX(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } fclose (exeFile); /* load entry point */ struct __argv args; bzero(&args, sizeof(args)); args.argvMagic = ARGV_MAGIC; args.length = strlen(cfgpath) + 2; args.commandLine = (char*)malloc(args.length); if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); strcpy(args.commandLine, cfgpath); args.commandLine[args.length - 1] = '\0'; args.argc = 1; args.argv = &args.commandLine; args.endARGV = args.argv + 1; int ret = valid_elf_image(exeBuffer); if (ret == 1) exeEntryPointAddress = load_elf_image(exeBuffer); else exeEntryPointAddress = load_dol_image(exeBuffer, &args); /* fadeout of image */ for(int i = 255; i > 1; i = i-7) { if(i < 0) i = 0; Background_Show(0, 0, 0, imgdata, 0, 1, 1, i); Menu_Render(); } SDCard_deInit(); USBDevice_deInit(); StopGX(); if (exeEntryPointAddress == 0) { printf("EntryPointAddress failed...\n"); Menu_Render(); sleep(3); fclose (exeFile); SDCard_deInit(); USBDevice_deInit(); StopGX(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);; } exeEntryPoint = (entrypoint) exeEntryPointAddress; /* cleaning up and load dol */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cookie); __exception_closeall (); exeEntryPoint (); _CPU_ISR_Restore (cookie); return 0; }
// Load an Image font file (XNA style) static SpriteFont LoadImageFont(Image image, Color key, int firstChar) { #define COLOR_EQUAL(col1, col2) ((col1.r == col2.r)&&(col1.g == col2.g)&&(col1.b == col2.b)&&(col1.a == col2.a)) int charSpacing = 0; int lineSpacing = 0; int x = 0; int y = 0; // Default number of characters supported #define MAX_FONTCHARS 256 // We allocate a temporal arrays for chars data measures, // once we get the actual number of chars, we copy data to a sized arrays int tempCharValues[MAX_FONTCHARS]; Rectangle tempCharRecs[MAX_FONTCHARS]; Color *pixels = GetImageData(image); // Parse image data to get charSpacing and lineSpacing for (y = 0; y < image.height; y++) { for (x = 0; x < image.width; x++) { if (!COLOR_EQUAL(pixels[y*image.width + x], key)) break; } if (!COLOR_EQUAL(pixels[y*image.width + x], key)) break; } charSpacing = x; lineSpacing = y; int charHeight = 0; int j = 0; while (!COLOR_EQUAL(pixels[(lineSpacing + j)*image.width + charSpacing], key)) j++; charHeight = j; // Check array values to get characters: value, x, y, w, h int index = 0; int lineToRead = 0; int xPosToRead = charSpacing; // Parse image data to get rectangle sizes while ((lineSpacing + lineToRead*(charHeight + lineSpacing)) < image.height) { while ((xPosToRead < image.width) && !COLOR_EQUAL((pixels[(lineSpacing + (charHeight+lineSpacing)*lineToRead)*image.width + xPosToRead]), key)) { tempCharValues[index] = firstChar + index; tempCharRecs[index].x = xPosToRead; tempCharRecs[index].y = lineSpacing + lineToRead*(charHeight + lineSpacing); tempCharRecs[index].height = charHeight; int charWidth = 0; while (!COLOR_EQUAL(pixels[(lineSpacing + (charHeight+lineSpacing)*lineToRead)*image.width + xPosToRead + charWidth], key)) charWidth++; tempCharRecs[index].width = charWidth; index++; xPosToRead += (charWidth + charSpacing); } lineToRead++; xPosToRead = charSpacing; } TraceLog(DEBUG, "SpriteFont data parsed correctly from image"); // NOTE: We need to remove key color borders from image to avoid weird // artifacts on texture scaling when using FILTER_BILINEAR or FILTER_TRILINEAR for (int i = 0; i < image.height*image.width; i++) if (COLOR_EQUAL(pixels[i], key)) pixels[i] = BLANK; // Create a new image with the processed color data (key color replaced by BLANK) Image fontClear = LoadImageEx(pixels, image.width, image.height); free(pixels); // Free pixels array memory // Create spritefont with all data parsed from image SpriteFont spriteFont = { 0 }; spriteFont.texture = LoadTextureFromImage(fontClear); // Convert processed image to OpenGL texture spriteFont.numChars = index; UnloadImage(fontClear); // Unload processed image once converted to texture // We got tempCharValues and tempCharsRecs populated with chars data // Now we move temp data to sized charValues and charRecs arrays spriteFont.charRecs = (Rectangle *)malloc(spriteFont.numChars*sizeof(Rectangle)); spriteFont.charValues = (int *)malloc(spriteFont.numChars*sizeof(int)); spriteFont.charOffsets = (Vector2 *)malloc(spriteFont.numChars*sizeof(Vector2)); spriteFont.charAdvanceX = (int *)malloc(spriteFont.numChars*sizeof(int)); for (int i = 0; i < spriteFont.numChars; i++) { spriteFont.charValues[i] = tempCharValues[i]; spriteFont.charRecs[i] = tempCharRecs[i]; // NOTE: On image based fonts (XNA style), character offsets and xAdvance are not required (set to 0) spriteFont.charOffsets[i] = (Vector2){ 0.0f, 0.0f }; spriteFont.charAdvanceX[i] = 0; } spriteFont.size = spriteFont.charRecs[0].height; TraceLog(INFO, "Image file loaded correctly as SpriteFont"); return spriteFont; }