public void Draw(STR_Bitmap <T> strbmBitmap, int iXOffset, int iYOffset, int iXo, int iYo, int iW, int iH, T gen_Color) { for (int y = 0; y < strbmBitmap.miHeightPx; y++) { int iYPixelCoord = y + iYOffset; if (iYPixelCoord < 0 || iYPixelCoord > miHeightPx) { continue; } for (int x = 0; x < strbmBitmap.miWidthPx; x++) { int iXPixelCoord = x + iXOffset; if (iXPixelCoord < 0 || iXPixelCoord > miWidthPx) { continue; } T gen_SourceColor = strbmBitmap.GetPixelAtCoord(x, y); int iColor = (STR_Utilities.GenericCast <T, int> .Do(gen_SourceColor)) * (STR_Utilities.GenericCast <T, int> .Do(gen_Color)); this.SetPixelAtCoord(x, y, STR_Utilities.GenericCast <int, T> .Do(iColor)); } } }
public void ScaleBlock(STR_Bitmap <T> strbmBitmap, int iScaleFactor, int iX, int iY, T gen_Color) { for (int y = 0; y < iScaleFactor; y++) { for (int x = 0; x < iScaleFactor; x++) { strbmBitmap.SetPixelAtCoord(x + iX, y + iY, gen_Color); } } }
private void DrawScaledPixel(STR_Bitmap <T> strbmBitmap, int iScaleFactor, int iX, int iY, T gen_Color) { for (int y = 0; y < iScaleFactor; y++) { for (int x = 0; x < iScaleFactor; x++) { strbmBitmap.SetPixelAtCoord(x + iX, y + iY, gen_Color); } } }
//public STR_Bitmap ( STR_Engine streEngine , int iBufferSize ) //{ // miWidthPx = streEngine.Window.WidthPx; // miHeightPx = streEngine.Window.HeightPx; // miBufferSize = iBufferSize; // m_strpb_gen_PixelBuffer = new STR_PixelBuffer_GEN<T> ( iBufferSize ); //} public STR_Bitmap(STR_Bitmap <T> strbmBitmap) { miWidthPx = strbmBitmap.miWidthPx; miHeightPx = strbmBitmap.miHeightPx; miBufferSize = strbmBitmap.miWidthPx * strbmBitmap.miHeightPx; if (miBufferSize != strbmBitmap.miBufferSize) { throw new Exception("ERR"); //TODO: write this message } m_strpb_gen_PixelBuffer = strbmBitmap.BufferObject; }
public STR_Bitmap <T> Scale(int iScaleFactor) { STR_Bitmap <T> strbmResult = new STR_Bitmap <T> (miWidthPx * iScaleFactor, miHeightPx * iScaleFactor); for (int y = 0; y < miHeightPx; y++) { for (int x = 0; x < miWidthPx; x++) { T gen_Color = GetPixelAtCoord(x, y); DrawScaledPixel(strbmResult, iScaleFactor, x, y, gen_Color); } } return(strbmResult); }
public void Blit(STR_Bitmap <T> strbmBitmap, int iXOffset, int iYOffset) { for (int y = 0; y < strbmBitmap.miHeightPx; y++) { int iYPixelCoord = y + iYOffset; if (iYPixelCoord < 0 || iYPixelCoord > miHeightPx) { continue; } for (int x = 0; x < strbmBitmap.miWidthPx; x++) { int iXPixelCoord = x + iXOffset; if (iXPixelCoord < 0 || iXPixelCoord > miWidthPx) { continue; } T gen_SourceColor = strbmBitmap.GetPixelAtCoord(x, y); this.SetPixelAtCoord(x, y, gen_SourceColor); } } }
public STR_Bitmap <T> Copy(STR_Bitmap <T> strbmSourceBitmap) => new STR_Bitmap <T> (strbmSourceBitmap);