public string?GetPrintScaleDescription() { try { var bytes = Directory.GetByteArray(PhotoshopDirectory.TagPrintScale); if (bytes == null) { return(null); } var reader = new ByteArrayReader(bytes); var style = reader.GetInt32(0); var locX = reader.GetFloat32(2); var locY = reader.GetFloat32(6); var scale = reader.GetFloat32(10); return(style switch { 0 => $"Centered, Scale {scale:0.0##}", 1 => "Size to fit", 2 => $"User defined, X:{locX} Y:{locY}, Scale:{scale:0.0##}", _ => $"Unknown {style:X4}, X:{locX} Y:{locY}, Scale:{scale:0.0##}", }); }
public virtual string GetPrintScaleDescription() { try { sbyte[] bytes = _directory.GetByteArray(PhotoshopDirectory.TagPrintScale); if (bytes == null) { return(null); } RandomAccessReader reader = new ByteArrayReader(bytes); int style = reader.GetInt32(0); float locX = reader.GetFloat32(2); float locY = reader.GetFloat32(6); float scale = reader.GetFloat32(10); switch (style) { case 0: { return("Centered, Scale " + scale); } case 1: { return("Size to fit"); } case 2: { return(Sharpen.Extensions.StringFormat("User defined, X:%s Y:%s, Scale:%s", locX, locY, scale)); } default: { return(Sharpen.Extensions.StringFormat("Unknown %04X, X:%s Y:%s, Scale:%s", style, locX, locY, scale)); } } } catch (Exception) { return(null); } }
public string GetPrintScaleDescription() { try { var bytes = Directory.GetByteArray(PhotoshopDirectory.TagPrintScale); if (bytes == null) { return(null); } var reader = new ByteArrayReader(bytes); var style = reader.GetInt32(0); var locX = reader.GetFloat32(2); var locY = reader.GetFloat32(6); var scale = reader.GetFloat32(10); switch (style) { case 0: return($"Centered, Scale {scale:0.0##}"); case 1: return("Size to fit"); case 2: return($"User defined, X:{locX} Y:{locY}, Scale:{scale:0.0##}"); default: return($"Unknown {style:X4}, X:{locX} Y:{locY}, Scale:{scale:0.0##}"); } } catch { return(null); } }
public void ProcessChunk(string fourCc, byte[] payload) { switch (fourCc) { case "strh": { string error = null; var reader = new ByteArrayReader(payload, isMotorolaByteOrder: false); string fccType = null; string fccHandler = null; float dwScale = 0; float dwRate = 0; int dwLength = 0; try { fccType = reader.GetString(0, 4, Encoding.ASCII); fccHandler = reader.GetString(4, 4, Encoding.ASCII); //int dwFlags = reader.GetInt32(8); //int wPriority = reader.GetInt16(12); //int wLanguage = reader.GetInt16(14); //int dwInitialFrames = reader.GetInt32(16); dwScale = reader.GetFloat32(20); dwRate = reader.GetFloat32(24); //int dwStart = reader.GetInt32(28); dwLength = reader.GetInt32(32); //int dwSuggestedBufferSize = reader.GetInt32(36); //int dwQuality = reader.GetInt32(40); //int dwSampleSize = reader.GetInt32(44); //byte[] rcFrame = reader.GetBytes(48, 2); } catch (IOException e) { error = "Exception reading AviRiff chunk 'strh' : " + e.Message; } var directory = new AviDirectory(); if (error == null) { if (fccType == "vids") { directory.Set(AviDirectory.TAG_FRAMES_PER_SECOND, (dwRate / dwScale)); double duration = dwLength / (dwRate / dwScale); int hours = (int)duration / (int)(Math.Pow(60, 2)); int minutes = ((int)duration / (int)(Math.Pow(60, 1))) - (hours * 60); int seconds = (int)Math.Round((duration / (Math.Pow(60, 0))) - (minutes * 60)); string time = new DateTime(2000, 1, 1, hours, minutes, seconds).ToString("hh:mm:ss"); directory.Set(AviDirectory.TAG_DURATION, time); directory.Set(AviDirectory.TAG_VIDEO_CODEC, fccHandler); } else if (fccType == "auds") { directory.Set(AviDirectory.TAG_SAMPLES_PER_SECOND, (dwRate / dwScale)); } } else { directory.AddError(error); } _directories.Add(directory); break; } case "avih": { string error = null; var reader = new ByteArrayReader(payload, isMotorolaByteOrder: false); int dwStreams = 0; int dwWidth = 0; int dwHeight = 0; try { //int dwMicroSecPerFrame = reader.GetInt32(0); //int dwMaxBytesPerSec = reader.GetInt32(4); //int dwPaddingGranularity = reader.GetInt32(8); //int dwFlags = reader.GetInt32(12); //int dwTotalFrames = reader.GetInt32(16); //int dwInitialFrames = reader.GetInt32(20); dwStreams = reader.GetInt32(24); //int dwSuggestedBufferSize = reader.GetInt32(28); dwWidth = reader.GetInt32(32); dwHeight = reader.GetInt32(36); //byte[] dwReserved = reader.GetBytes(40, 4); } catch (IOException e) { error = "Exception reading AviRiff chunk 'avih' : " + e.Message; } var directory = new AviDirectory(); if (error == null) { directory.Set(AviDirectory.TAG_WIDTH, dwWidth); directory.Set(AviDirectory.TAG_HEIGHT, dwHeight); directory.Set(AviDirectory.TAG_STREAMS, dwStreams); } else { directory.AddError(error); } _directories.Add(directory); break; } } }