static int CalcBlockNumber(ColumnParams colParams, int[,] lut, int blockX, int blockY, int texBufWidth) { int pageX = blockX / colParams.ColsPerPage; int pageY = blockY / colParams.RowsPerPage; int blockXInPage = blockX % colParams.ColsPerPage; int blockYInPage = blockY % colParams.RowsPerPage; return((pageY * texBufWidth + pageX) * BLOCKS_PER_PAGE + lut[blockYInPage, blockXInPage]); }
public DataGridTextColumnAdvanced(ColumnParams par) { this.par = par; IsReadOnly = par.IsReadOnly; Visibility = par.Visible ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden; Header = par.HeaderLocalized; ColumnParams = par; Binding = new Binding(par.LocalizationKey); }
public static void WriteColumn(BinaryWriter bw, TxmPixelFormat format, int bytesPerLine, byte[] data) { ColumnParams colParams = GetColumnParams(format); int bytesPerDestLine = colParams.Width * colParams.BitsPerPixel / 8; int skipLength = bytesPerLine - bytesPerDestLine; for (int i = 0; i < colParams.Height; ++i) { bw.Write(data, i * bytesPerDestLine, bytesPerDestLine); bw.Seek(skipLength, SeekOrigin.Current); } }
static int CalcBlockMemoryOffset(ColumnParams colParams, int[] lut, int index) { int pageIndex = index / BLOCKS_PER_PAGE; int rem = index % BLOCKS_PER_PAGE; int pixelsPerBlock = colParams.Width * colParams.Height * COLUMNS_PER_BLOCK; int memBlockNum = lut[rem]; int fullBlockRows = memBlockNum / colParams.ColsPerPage; int partialBlocks = memBlockNum % colParams.ColsPerPage; return(( pageIndex * BLOCKS_PER_PAGE * pixelsPerBlock + // Full pages fullBlockRows * pixelsPerBlock * colParams.ColsPerPage + // Full row of blocks partialBlocks * colParams.Width // Partial row of blocks ) * colParams.BitsPerPixel / 8); }
public static byte[] ReadColumn(BinaryReader br, TxmPixelFormat format, int bytesPerLine) { ColumnParams colParams = GetColumnParams(format); byte[] data = new byte[colParams.Width * colParams.Height * colParams.BitsPerPixel / 8]; int bytesPerDestLine = colParams.Width * colParams.BitsPerPixel / 8; int skipLength = bytesPerLine - bytesPerDestLine; for (int i = 0; i < colParams.Height; ++i) { byte[] lineData = br.ReadBytes(bytesPerDestLine); br.BaseStream.Seek(skipLength, SeekOrigin.Current); Buffer.BlockCopy(lineData, 0, data, i * bytesPerDestLine, lineData.Length); } return(data); }
public static int CalcTxmImageOffset(ColumnParams colParams, int blockIndex, int imageWidth) { int blocksPerRow = imageWidth / colParams.Width; if (blocksPerRow == 0) { blocksPerRow = 1; } int fullRows = blockIndex / blocksPerRow; int rowBlockIndex = blockIndex % blocksPerRow; return(( fullRows * imageWidth * colParams.Height * 4 + rowBlockIndex * colParams.Width ) * colParams.BitsPerPixel / 8); }
public static int CalcBlockMemoryOffset(TxmPixelFormat format, int index) { ColumnParams colParams = GetColumnParams(format); switch (format) { case TxmPixelFormat.PSMCT32: return(CalcBlockMemoryOffset(colParams, PSMCT32_BLOCK_REVERSE_LOOKUP, index)); case TxmPixelFormat.PSMT8: return(CalcBlockMemoryOffset(colParams, PSMT8_BLOCK_REVERSE_LOOKUP, index)); case TxmPixelFormat.PSMT4: return(CalcBlockMemoryOffset(colParams, PSMT4_BLOCK_REVERSE_LOOKUP, index)); default: throw new NotSupportedException($"{format} not supported"); } }
public static int CalcBlockNumber(TxmPixelFormat format, int blockX, int blockY, int texBufWidth) { ColumnParams colParams = GetColumnParams(format); switch (format) { case TxmPixelFormat.PSMCT32: return(CalcBlockNumber(colParams, PSMCT32_BLOCK_LOOKUP, blockX, blockY, texBufWidth)); case TxmPixelFormat.PSMT8: return(CalcBlockNumber(colParams, PSMT8_BLOCK_LOOKUP, blockX, blockY, texBufWidth)); case TxmPixelFormat.PSMT4: return(CalcBlockNumber(colParams, PSMT4_BLOCK_LOOKUP, blockX, blockY, texBufWidth)); default: throw new NotSupportedException($"{format} not supported"); } }
public ColumnParamsCollection GetColumns(string databaseName, string tableName, bool isView) { this._qryExec = true; try { string tblNm, usrNm; rsDbSql.ParseSchemaAndTableName(tableName, out tblNm, out usrNm); this.CheckConnectionReady(); ColumnParamsCollection cols = new ColumnParamsCollection(null); string qry = string.Format("SELECT sc.name, st.name, sc.colorder, sc.length, sc.colstat, sc.isnullable, so.uid FROM {0}.sys.syscolumns sc INNER JOIN {0}.sys.sysobjects so ON sc.id = so.id AND so.id = (SELECT so2.id FROM {0}.sys.sysobjects so2 INNER JOIN {0}.sys.schemas su2 ON su2.schema_id = so2.uid AND su2.name = '{2}' WHERE so2.name = '{1}' AND so2.xtype=N'{3}') INNER JOIN {0}.dbo.systypes st ON st.xtype = sc.xtype ORDER BY sc.colorder", databaseName, tblNm, usrNm, (!isView) ? "U" : "V"); using (SqlCommand cmd = new SqlCommand(qry, this.DbConnection)) using (SqlDataReader rdr = cmd.ExecuteReader()) while (rdr.Read()) { if (rdr.GetValue(1).ToString() == "sysname") // I don't know exactly what this is, but the query actually returns an "extra" record for each column, with a datatype of "sysname" continue; ColumnParams cp = new ColumnParams(); //rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString(), int.Parse(rdr.GetValue(3).ToString())); cp.ColumnName = rdr.GetValue(0).ToString(); SqlDbType colType = SqlDbType.Variant; try { colType = (SqlDbType)Enum.Parse(typeof(SqlDbType), rdr.GetValue(1).ToString(), true); } catch { colType = SqlDbType.Variant; } cp.DataType = colType; int fldSz; if (!int.TryParse(rdr.GetValue(3).ToString(), out fldSz)) fldSz = -1; cp.FieldSize = fldSz; cp.IsIdentity = (rdr.GetValue(4).ToString() == "1"); cp.IsNullable = (rdr.GetValue(5).ToString() == "1"); cp.SetOrdinal(int.Parse(rdr.GetValue(2).ToString())); string colKeyBase = string.Format("{0}.{1}.{2}.{3}", databaseName, usrNm, tblNm, rdr.GetValue(0)); string colKey = colKeyBase; int colKeyCnt = 1; while (cols.ContainsKey(colKey)) colKey = colKeyBase + (colKeyCnt++).ToString().PadLeft(2, '0'); cols.Add(cp, colKey); } return cols; } catch { throw; } finally { this._qryExec = false; } }