private void uploadToLEDBoardToolStripMenuItem_Click(object sender, EventArgs e) { solution.SaveAll(); lb_manager = new LED_Board_Manager(); lb_manager.Size = new Size(425, 180); string ProjectFileName = solution.GetItemPath(solution.GetProject()); lb_manager.AddFile(ProjectFileName); foreach (IDocument item in solution.GetProjectItems(solution.GetProject())) { Document document = solution.GetItemDocument(item); string path = document.GetPath(); lb_manager.AddFile(path); if (item.GetType() == typeof(Theme)) { Theme theme = item as Theme; foreach (LB_Tools_Interface tool in theme.GetTools()) { string tool_res; if (tool.GetType() == typeof(LB_Tools_Text)) { LB_Tools_Text tool_text = tool as LB_Tools_Text; tool_res = Path.GetDirectoryName(ProjectFileName) + "\\" + "LB_Tools_Text_" + tool_text.Text_Name + ".bma"; tool_text.SetLBResourcePath(tool_res); AnimationConverter animationConverter = new AnimationConverter(tool_text.GetBitmap()); if (animationConverter.Encode(tool_res, 0, 0, AnimationConverter.ColorOrder.RGB, AnimationConverter.PixelOrder.VS_TR, AnimationConverter.DataType.Default)) { lb_manager.AddFile(tool_res); } } else if (tool.GetType() == typeof(LB_Tools_RunningText)) { LB_Tools_RunningText tool_rtext = tool as LB_Tools_RunningText; tool_res = Path.GetDirectoryName(ProjectFileName) + "\\" + "LB_Tools_Text_" + tool_rtext.Text_Name + ".bma"; CloseTabIfOpened(theme); if (tool_rtext.SaveAsBMA(tool_res)) { lb_manager.AddFile(tool_res); } } else { tool_res = tool.GetLBResourcePath(); if (tool_res != "") { lb_manager.AddFile(tool_res); } } } } } lb_manager.Show(); }
private void LoadImage() { if (ImagePath != ImagePathOld && ImagePath != "") { ImagePathOld = ImagePath; FileInfo f_info = new FileInfo(ImagePath); switch (f_info.Extension) { case ".bmp": if (f_info.Extension == ".bmp") { Bitmap tempBitmap = new Bitmap(ImagePath); if (tempBitmap.Height > MaxSize.Height || tempBitmap.Width > MaxSize.Width) { bitmap = new Bitmap(MaxSize.Width, MaxSize.Height); Graphics g = Graphics.FromImage(bitmap); g.DrawImage(tempBitmap, new Rectangle(0, 0, MaxSize.Width, MaxSize.Height)); tempBitmap.Dispose(); } else { bitmap = new Bitmap(tempBitmap); tempBitmap.Dispose(); } animationConverter = new AnimationConverter(bitmap); string bma_path = Path.GetDirectoryName(ImagePath) + "\\" + Path.GetFileNameWithoutExtension(ImagePath) + ".bma"; if (animationConverter.Encode(bma_path, 0, 0, AnimationConverter.ColorOrder.RGB, AnimationConverter.PixelOrder.VS_TR, AnimationConverter.DataType.Default)) { LbResourcePath = bma_path; LbResourceName = LB_Tools.GetFileName(LbResourcePath); } } break; case ".jpg": Stream imageStreamSource = new FileStream(ImagePath, FileMode.Open, FileAccess.Read, FileShare.Read); JpegBitmapDecoder decoder = new JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); BitmapSource bitmapSource = decoder.Frames[0]; bitmap = BitmapFromSource(bitmapSource); break; default: break; } } }
public bool SaveAsBMA(string path) { if (path == "") { return(false); } bitmap = new Bitmap(1, 8); GetBitmap(); int frames = ActiveFrame.Width; ActiveFrameX = 0.0; ActiveFrame.X = 0; int x = 0; AnimationConverter animationConverter = new AnimationConverter(TextArea.Width, TextArea.Height); while (frames > 0) { GetBitmap(); if (x != ActiveFrame.X) { x = ActiveFrame.X; frames--; } } frames = SpaceWidth + TextSize.Width + 1; while (frames > 0) { animationConverter.AddFrame(GetBitmap()); if (x != ActiveFrame.X) { x = ActiveFrame.X; frames--; } } if (animationConverter.Encode(path, 0, animationConverter.animation.FramesCount - 1, AnimationConverter.ColorOrder.RGB, AnimationConverter.PixelOrder.VS_TR, AnimationConverter.DataType.Default)) { SetLBResourcePath(path); return(true); } return(false); }