Visual Info Processing Programming Guide

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Advertisements

Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
MFC Workshop: Intro to MFC. What is MFC? Microsoft Foundation Classes C++ wrappers to the Windows SDK An application framework A useful set of extensions.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
A First Program Using C#
Microsoft Visual Basic 2005: Reloaded Second Edition
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
Overview of Previous Lesson(s) Over View  Microsoft Foundation Classes (MFC)  A set of predefined classes upon which Windows programming with Visual.
Microsoft Foundation Classes. What is MFC? Set of C++ classes written by MS Simplifies writing complex programs Covers many areas: – GUI – I/O – O/S interfaces.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
Using Xcode A Beginner’s Tutorial Erin Green. This tutorial will walk you through Xcode, a software development tool for Apple’s iOS applications – We.
Bitmap (Chapter 15).
Processing Workshop. What is processing? “Processing is an open source programming language and environment for people who want to program images, animation,
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
Creating a Java Application and Applet
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Programming with Visual Studio MFC and OpenGL. Outline Creating a project Adding OpenGL initialization code and libraries Creating a mouse event Drawing.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Lesson 1 – Getting Started with App Inventor
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
Chapter 1: Introduction to Computers and Programming
Dive Into® Visual Basic 2010 Express
Introduction to Windows Programming
Message Handling in MFC
Microsoft Foundation Classes MFC
Topics Introduction Hardware and Software How Computers Store Data
Chapter 1: An Introduction to Visual Basic 2015
Chapter Topics 15.1 Graphical User Interfaces
Visual Info Processing Programming Guide (More Details)
Chapter 8: Writing Graphical User Interfaces
Computer 4 JEOPARDY Bobbie, Sandy, Trudy.
Console and GUI Programs
3.01 Apply Controls Associated With Visual Studio Form
Windows Programming Model
Program and Graphical User Interface Design
3.01 Apply Controls Associated With Visual Studio Form
Java Programming: Guided Learning with Early Objects
Understand Windows Forms Applications and Console-based Applications
Windows Desktop Applications
Chapter 5 Working with Images
Program and Graphical User Interface Design
Chapter 1: Introduction to Computers and Programming
Getting Image Data Image Data Files 11/15/2018
Chapter 2 – Introduction to the Visual Studio .NET IDE
Hands-on Introduction to Visual Basic .NET
Welcome to E-Prime E-Prime refers to the Experimenter’s Prime (best) development studio for the creation of computerized behavioral research. E-Prime is.
CIS16 Application Development Programming with Visual Basic
Event loops.
Topics Introduction Hardware and Software How Computers Store Data
Lecture Set 11 Creating and Using Classes
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Chapter 3 – Introduction to C# Programming
COMS 161 Introduction to Computing
Chapter 15: GUI Applications & Event-Driven Programming
Visuals are analog signals...
Model, View, Controller design pattern
Event loops.
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Event loops.
Chapter 4 Enhancing the Graphical User Interface
MAINTAINING FILES AND CUSTOMIZING WINDOWS Section 2
Presentation transcript:

Visual Info Processing Programming Guide

Outline windows programming MFC (Microsoft Foundation Classes) Visual studio Basic image loading, operation (sample program) menu creation

Windows Programming Prepare Your Development Environment To write a Windows program in C or C++, you must install the Windows SDK or a development environment that includes the Windows SDK, such as Microsoft Visual C++. 

Windows Coding Conventions If you are new to Windows programming, it can be disconcerting when you first see a Windows program. The code is filled with strange type definitions like DWORD_PTR and LPRECT, and variables have names like hWnd and pwsz (called Hungarian notation). It's worth taking a moment to learn some of the Windows coding conventions.

WinMain: The Application Entry Point Every Windows program includes an entry-point function that is named either WinMain or wWinMain. Here is an empty WinMain function. INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) { return 0; }

Windows Hello World Sample http://msdn.microsoft.com/en- us/library/ff485851(v=VS.85).aspx

What is windows? This type of window is called an application window. The area within the frame is the client area.

What is MFC? Microsoft Foundation Classes C++ wrappers to the Windows SDK An application framework A useful set of extensions MFC SDK Windows

Why MFC? Eliminates a lot of the monotony of Windows programming. Written in C++ Code reuse saves time Relatively easy for C++ programmers to pick up Most Windows objects act like C++ objects in MFC Small amount of overhead for a class library You can still access the SDK.

How to use MFC Derive the from classes to add functionality. Override base class members. Add new members.

Microsoft Foundation Class Library Class is a concept in object-oriented programming. In our sample program, we majorly concern 2 classes. MFC represents Windows components (menus, dialogs) as classes. It's recommended to add the event handlers in the CKingImageView class

User Interfaces (UI) The UI is the connection between the user and the computer Command line/console Text based Graphical User Interface (GUI) Visually oriented interface (WYSIWIG) User interacts with graphical objects More intuitive Other UIs: optical, speech-based, etc.

User Interaction Users interact with the GUI via messages When a GUI event occurs the OS sends a message to the program Programming the functions that respond to these messages is called event-driven programming Messages can be generated by user actions, other applications, and the OS

Event-driven programming Structure GUI programs to respond to user events Events are: mouse clicks, mouse moves, keystrokes, etc. in MFC parlance, usually called messages Main control structure is an event loop: while (1) { wait for next event dispatch event to correct GUI component } this code is always the same, so it’s handled by MFC You just write the code to respond to the events. functions to do this are called message handlers in MFC GUI model is: user should be able to give any input at any time  Non-Sequential!

Adding to a message map To have your class do something in response to a message: 1. Add DECLARE_MESSAGE_MAP statement to the class declaration 2. In the implementation file, place macros identifying the messages the class will handle between calls to BEGIN_MESSAGE_MAP and END_MESSAGE_MAP need to tell it the class name and the superclass name Example: BEGIN_MESSAGE_MAP(CHello2View, CView) ON_WM_LBUTTONDOWN() END_MESSAGE_MAP() 3. Add member functions to handle the messages (uses fixed naming scheme). Here’s an example function prototype: afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

Message maps Visual studio can add this code for us.

View object Displays document data and typically allows users to enter and modify data Can have more than one view (as in Excel) May only show part of the data Data may be too large to display May only display a certain type of data Principle graphic user interface Handles most commands especially Paint (draw), Print, Inputs (WM_CHAR) etc.

Bitmap Format File Header: Image Data: Type, size of file, reserved dword, offset to image data, size of header, width, height, color planes, color depth, compress flag, size of image data, horizontal resolution, vertical resolution, number of colors, important colors, RGB palettes. Image Data: The actual image data of the file. From bottom-left. Padding bytes. Use software to convert bitmap images.

Bitmap Pixel storage The bits representing the bitmap pixels are packed in rows. The size of each row is rounded up to a multiple of 4 bytes (a 32-bit DWORD) by padding. The total amount of bytes necessary to store an array of pixels in an n Bits per Pixel (bpp) image, with 2n colors, can be calculated by accounting for the effect of rounding up the size of each row to a multiple of a 4 bytes, as follows

Visual Studio 20XX You can download the sample code from http://www.cs.binghamton.edu/~lijun/CS5 55_Fall2011/2011Fall_CS555.html

Load the project into Visual Studio, all the classes defined are displayed in the left window. Double click a class the contents of its header file or source file will be displayed in the right window. When you compile and run it, you will see an application window and some menu items ready but won’t response yet.

The project navigator shows you the files that make up your project The project navigator shows you the files that make up your project. These files can be grouped into folders to help you organize your project.

After you have read in an image, all the data will be saved in a CKingImageDoc object. As displaying functions are build in CkingimageView class you will need this line to handle the image object in view class.

Next in the view Class by calling int iBitPerPixel = pDoc->_bmp->bitsperpixel; int iWidth = pDoc->_bmp->width; int iHeight = pDoc->_bmp->height; BYTE *pImg = pDoc->_bmp->point;

“iBitPerPixel” has value of 8 or 24 to represent grayscale or 24 bit true color image respectively. To access the value of a pixel at ith row and jth column, use: pImg[i*iWidth+j] = 255; //set the pixel of a grayscale image to white or for a 24 bit color image; pImg[i*iWidth*3+j*3] = 0; //Blue bit pImg[i*iWidth*3+j*3+1] = 0; //Green pImg[i*iWidth*3+j*3+2] = 0; //Red

CKingimageView::OnDraw(CDC CKingimageView::OnDraw(CDC* pDC) is responsible to draw the image on current device context. After you have modified image data, call OnDraw to redraw the screen.

Add new menu

Common bugs So be careful using data type conversion. Always use explicit conversion – casting. double g = grayscale; pImg[i*iWidth+j] = (BYTE) g; Check if the value of the grayscale is between 0 and 255! if (g < 0.0) g = 0.0; else if (g > 255.0) g = 255.0; else {…}

Common bugs Original image overwritten! Define an array to store the image data. double *arr = new double ... ; for (…) { arr[i*iWidth+j] = (double) pImg[i*iWidth+j]; }

Common bugs Mask template. Use 2 arrays, one as input, one as output.

tools msdn sample code and tutoail Youtube Visual Studio Tutorial Google Email me or come to my office hour

Verify your result. Compare your output image with professor’s examples. Use GIMP or Photoshop to verify your results. Use your eyes to verify your results.

demo Sample code Assignment code

Please ask as early as possible. The End Questions? Please ask as early as possible.