Finidng the missing segments and return to the output

Hello All,
I am working on finding the missing segments which doesn't have a code value. I have 2 tables, Line and Code.
In the line table I have below columns
Line_ID                  BeginMeasure                   EndMeasure
1                                0                                     
100
2                                0                                     
200
3                                0                                      300
In the code table I may have multiple records for each line
Line_ID                       BeginMeasure                 
EndMeasure                   code
1                                  12                                   
30                                    3
1                                   40                                  
50                                    4
2                                  0                                     
150                                  6
3                                  30                                   
300                                  8
Here I need to find out the segments which doesn't have a code value. For example, for Line_ID 1 in the code table we dont have a value for the code for 0 -12, 30 - 40 and 50 - 100 segments and for Line_ID 2, we dont have code for 150 - 200 segment.
I want the  records which doesn't have code value defined in the output result set and the expected result set should be like below
Line_ID                           BeginMeasure                    
EndMeasure
1                                        0                                           
12
1                                        30                                         
40
1                                        50                                          
100
2                                       150                                         
200
3                                         0                                            
30
Any code suggestions/help is greatly appreciated.
Thanks so much

Declare @vLine Table (id int, BM int, EM int)
Declare @vCode Table (id int, LineID int, BM int, EM int, code int)
Insert into @vLine
Select 1,0,100 Union All
Select 2,0,200 Union All
Select 3,0,300
Insert into @vCode
Select 1,1,12,30,3 Union All
Select 2,1,40,50,4 Union All
Select 3,2,0,150,4 Union All
Select 4,3,30,300,4
--;with wcte as
-- Select *
-- from @vLine a
-- Inner Join @vCode b on b.id = a.id
Select a.ID, a.BM, a.EM,b.BM,b.EM,b.code
from @vLine a
Inner Join @vCode b on b.LineID = a.id -- 1
Declare @vLineID int
Declare @vCodeID int
Declare @vInsertedID int
Declare @vLineMaxVal int, @vLineMinVal int, @vCodeMaxval int, @vCodeMinVal int, @vCodeInt int
Declare C1 Cursor for
Select a.ID, a.BM, a.EM,b.BM,b.EM,b.code
from @vLine a
Inner Join @vCode b on b.LineID = a.id -- 1
--Where a.ID = 2
open C1
Fetch Next from C1 into @vLineID, @vLineMinVal , @vLineMaxVal , @vCodeMinval , @vCodeMaxVal , @vCodeInt
Declare @vResult Table (ID int IDENTITY(1,1), LineID int, MissVal1 int, MissVal2 int)
Set @vCodeID = @vLineID
While @@Fetch_Status = 0
begin
print @vCodeID
print @vLineID
While @vCodeID = @vLineID and @@FETCH_STATUS = 0
begin
--Select @vCodeMinVal , @vLineMinVal
if @vCodeMinVal > @vLineMinVal
begin
if Exists (Select 1 from @vResult where LineID = @vLineID and MissVal2 = @vLineMaxVal)
begin
Update @vResult
Set MissVal2 = @vCodeMinVal
where LineID = @vLineID and MissVal2 = @vLineMaxVal
end
else
begin
Insert into @vResult
Select @vLineID, @vLineMinVal, @vCodeMinVal
Select @vInsertedID = SCOPE_IDENTITY()
end
end
if @vLineMaxVal > @vCodeMaxval
begin
Insert into @vResult
Select @vLineID, @vCodeMaxVal, @vLineMaxVal
Select @vInsertedID = SCOPE_IDENTITY()
end
Fetch Next from C1 into @vLineID, @vLineMinVal , @vLineMaxVal , @vCodeMinval , @vCodeMaxVal , @vCodeInt
print @vCodeID
print @vLineID
if @vCodeID <> @vLineID
BREAK
end
Set @vCodeID = @vLineID
--Fetch Next from C1 into @vLineID, @vLineMaxVal , @vLineMinVal , @vCodeMaxval , @vCodeMinVal , @vCodeInt
end
Deallocate C1
Select * from @vResult
Please visit my Blog for some easy and often used t-sql scripts
My BizCard

Similar Messages

  • What is the difference between a tablespace, a segment and an extent ?

    What is the difference between a tablespace, a segment and an extent ? Please explain in layman terms since I'm a total newbie to Oracle.
    Regards
    Gony

    Hi,
    These are logical structure of database
    1. Tablespace : A database is divided into logical storage units called tablespaces, which group related logical structures together. For example, tablespaces commonly group together all application objects to simplify some administrative operations.
    2.Segments
    Above extents, the level of logical database storage is a segment. A segment is a set of extents allocated for a certain logical structure. The following table describes the different types of segments.
    Segment Description
    Data segment
    Each nonclustered table has a data segment. All table data is stored in the extents of the data segment.
    For a partitioned table, each partition has a data segment.
    Each cluster has a data segment. The data of every table in the cluster is stored in the cluster's data segment.
    Index segment
    Each index has an index segment that stores all of its data.
    For a partitioned index, each partition has an index segment.
    Temporary segment
    Temporary segments are created by Oracle when a SQL statement needs a temporary work area to complete execution. When the statement finishes execution, the extents in the temporary segment are returned to the system for future use.
    Rollback segment
    If you are operating in automatic undo management mode, then the database server manages undo space using tablespaces. Oracle Corporation recommends that you use "Automatic Undo Management" management.
    3. Extents
    The next level of logical database space is an extent. An extent is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information.

  • I am having an issue where safari keeps crashing and returning to the home screen on an ipad1

    safari on my ipad1 keeps crashing and returning to the home screen. rebooting does not fix the problem neither has a full reset through itunes from a backup or setting up as a new machine. Cab nay body help?

    If restoring from a backup doesn't help, you must have something corrupt in the backup - like a Safari bookmark perhaps - or something in the Safari history. Try the last tip in this list first.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Close Safari and all apps. Go to the home screen first by tapping the home button. Quit/close open apps by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus (-) sign in the upper left corner to close the apps. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Go to Settings>Safari>Clear History, Cookies and Cache. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • How can I make one cell search multiple other cells for a string of text and return whether or not the string appeared in the cells searched?

    https://www.icloud.com/iw/#numbers/BAI31boMQXsGKc8NH22BlqWRzbs8PdgWBs-F/2014-15_ Curriculum_Planning_w_CCSS_(Web_Shared)
    My document is above, if anyone wants to help this crazy teacher invent a better lesson planner.
    Here's my predicament.  The state in which I teach requires teachers to keep up with which of the Common Core State Standards (CCSS) their instruction is addressing and when the standards were addressed.  I got the bright idea to do this through a spreadsheet in Numbers because our school is getting iPads this year, so it'd be pretty sweet to be able to assemble all of my lesson plans in one massive spreadsheet.  On the "AP Lesson Plans" sheet, I've got a few weeks worth of lesson plans entered in.  I'm planning on going in and using the drop-down menu next to each lesson plan to add all the CCSS on a per-day basis.  This is simple enough, but here's where I run into a problem.
    I want the "AP Standards" sheet to concatenate, in cells D3 through G76, the dates on which a standard was covered.  What I need is some way for, say, Cell D3 to look at the table on the "AP Lesson Plans" sheet and concatenate the dates of every lesson which has the standard in column A (In this instance, RL.11-12.1).  At the end of the day, the functionality I need is that I can enter my lessons and CCSS on the "AP Lesson Plans" sheet and go to the other sheet and see a summary of which standards have been addressed, when, and how often.
    If that's as clear as mud, well, I teach literature, not technical writing, so my apologies.  I'm more at home with Jonathan Swift than spreadsheets.  I'll gladly help you help me if you'd let me know what you need to know.  Oh, and to illustrate my knowledge level (just enough to be dangerous), I've left you the formula of my best stab at making cell D3 behave as desired.  It's the gray box on the "AP Standards" sheet.  Yikes.

    Hi Arrdenet,
    Congratulations on the nested IFs. I haven't tested that formula, but it is impressive. It will be very difficult to debug if it doesn't work, and I think it would make Numbers very slow.
    Here is a different approach. After you enter all the CCSS, add another column with HLOOKUP.
    Edit:
    B2 (and Fill Down)
    A2 (and Fill Down)
    =IFERROR(HLOOKUP(A$1,C2:E2,1,0),"")
    HLOOKUP looks for the value in A1 in all the CCSS columns.
    IFERROR is to stop the error triangles appearing and returns "" (NULL) instead.
    Then sort by column A.
    Not a complete answer, but it might get you started.
    Regards,
    Ian.

  • Whats the difference between producing output and returning a value?

    I've just started learning Java. I am having difficulty understanding what it means to "return a value".
    If a method has an argument, then whenever this method is called the variable named will be used for output.
    If you create a method to return a new value rather than display it, you would exchange the 'void' for 'double' e.g. public static double predictRaise(double moneyAmount). My book states that a return statement causes a value to be sent from a called method back to the calling method. Their example is not clear to me. Here is what they show for when only 'output' is produced:
    <code>
    Public static void predictRaiseUsingRate (double money, double rate)// 2 arguments
              double newAmount;
              newAmount = money * (1 + rate);
              System.out.println (?With raise, new salary is ? + newAmount);
    </code>
    And their example of a returned value:
    <code>
    public static double predictRaise(double moneyAmount)
              double newAmount;     
              newAmount = moneyAmount * 1.10;
              return newAmount;
    </code>
    Their explanation: "This return statement causes a value to be sent from a called method back to the calling method. The value stored in newAmount is      sent back to any method that calls predictRaise() method."
    For some reason this is just not sinking in. Does anyone have a better example/explanation? I could not find anything with a better explanation in archives.
    Are they tring to tell me: "if the original method declares an argument that is declared as 257 in the method call, that when that same method is called again, it will always be 257? But if you do a return statement, any changes in the return statement will now always be used in all methods calling that method?
    Thanks for your help.
    Gizelle

    To use an older and possibly more easily understood terminology. Methods can either be "functions" almost in the mathematical sense or they can be "procedures" in the sense of a process.
    A function is a mapping between a "domain", its arguments, and a "range", its result. An example of a function in mathematics is cosine, which takes an argument in degrees or radians and returns a result between -1 and 1. In java functions are just methods that declare a result type. eg. public int foo(int arg).
    A procedure is a program that doesn't return any result, it's not something that fits well into mathematics, but it occurs all the time in real life. For example, walking the dog does not map something from a domain to a range, but it may have some side effects, which is why I always carry a plastic bag with me. Procedures in java are methods that are declared as "void". eg. public void foo(int arg).
    All the well known arithmetic operations are functions, they take one or two arguments in the domain of numbers and return a result in the same set. Eg, x = a + b, the operator + is a function that takes two numbers, calculates the arithmetic sum of them and returns a result. Functions are very handy since you can string them together, eg. z = a+foo(b)*max(c+d). This doesn't work with procedures.
    Procedures are often used for much longer and more involved operations, there is no immediate result, but a lot of things may occur while they run. Data may be printed on a screen or paper, a database or file may get updated and email messages might get send. But no other expession is waiting for a resulting value so it can carry on. Procedures may also happen asynchonously, ie. outside the timeframe of their caller, see threads. Functions cannot do this, or if they do, they turn into procedures by throwing away their result. For example, you can schedule a procedure to send an email to your friends every Friday inviting them to go out for drinks, but you don't wait around for the result.
    In a way functions are a bit like phone calls, you wait for a response, procedures are more like snail mail, you send it off and check on what happened later.
    I hope this helps.

  • My assistant and I are using two Lightrooms (i.e. two serial numbers) and need to share between our two computers. I provide originals to her onto a flash drive. She tags them and returns them to me. I then copy the photos from her flash drive onto my com

    My assistant and I are using two Lightrooms (i.e. two serial numbers) and need to share between our two computers. I provide originals to her onto a flash drive. She tags them and returns them to me. I then copy the photos from her flash drive onto my computer and load them in my LR. The photos appear but witthout any editing or tagging. We need to be able to have her working on the photos on her computer with her copy of LR and me on my computer with my version of LR being able to access what is already tagged and given back to me. This seems hard. We need advice on if it is at all possible to have two computers simultaneously working on LR . I bought her her own version because I was told at the time of purchasing that that was the only way to share. Please advise urgently! Thanks.

    Sounds like your assistant isn't instructing Lightroom to write the tagging and editing to the files themselves, so wehn the files return to you, they don't have editing and tagging information. She need to select the photos in Lightroom and then Ctrl-S (Cmd-S on Mac). Or alternatively turn on the option to autmoatically write this information to the files.
    If you are using RAW photos, then this information will be written to a sidecar XMP file, and your assistant must provide you with the sidecar file. If these photos are not RAW photos, then the information is written directly into the photo file itself.
    Lightroom wasn't designed to be a multi-user program, and so it is truly not possible to have two people working on the same catalog at once. The way you are doing things, as modified above, is probably the way to go.
    As an alternative, you can transfer (portions of) catalogs as well as photos back and forth and then all of these issues disappear, but a catalog might be rather large for a flash drive (or maybe not, it depends)

  • HT4314 Hello, I have an Iphone 3GS and can't connect to Game Center.  It recognizes my apple ID account, states it was never used with Game Center. Then asks for country, birthdate, then returns to ask country again, then birthdate, and returns to the loo

    Hello, I have an Iphone 3GS and can't connect to Game Center.  It recognizes my apple ID account, states it was never used with Game Center. Then asks for country, birthdate, then returns to ask country again, then birthdate, and returns to the loop. Never ends the loop unless I cancel the setup process.  I have restored the iphone to the factory settings and restored the backup, but did not work. Any suggestions on what can be the problem? thank you.

    I just read another post that says you can go into a game that allows for multiple players and utalizes game center and enter your account information that way.  I haven't tried it yet, but it seems to work for others that had this issue.

  • How can you keep your iPhone 4 (using it as my car's iPod) staying on the Audible app?  When I leave the car and return to continue hearing a book, it has switched to iTunes.

    How can you keep your iPhone 4 (using it as my car's iPod) staying on the Audible app?  When I leave the car and return to continue hearing a book, it has switched to iTunes.

    The first time an iPhone is connected to iTunes that is used to sync with another iPhone or iOS device, you are prompted to transfer the backup for the other iPhone or iOS device or to set up the iPhone as a new iPhone.
    The former does as provided - it transfers the backup for the other iPhone or iOS device to the iPhone replacing all data on the iPhone that is included with the backup being transferred. The latter does nothing allowing you to make your various selections for the iPhone sync preferences with iTunes.
    This is designed to be done right away with a new iPhone.
    If you don't have a backup for the iPhone with iTunes on your computer and don't have an iCloud backup that hasn't been updated since choosing to transfer the backup for your iPod Touch to the iPhone, the data that was on the iPhone is gone.

  • How can i change the method that get a Bitmap file and return 15 new Bitmaps so the new Bitmaps will be also PixelFormat Format8bppIndexed ?

    This is the method:
    public static Bitmap[] get_images_with_clouds(Bitmap radar_image)
    int e = 0;
    int f = 0;
    int image_clock_area_x = 0;
    int image_clock_area_y = 0;
    int image_clock_area_x1 = 140;
    int image_clock_area_y1 = 21;
    Bitmap[] localImages;
    localImages = new Bitmap[15];
    Bitmap image;
    image = new Bitmap(Properties.Resources.radar_without_clouds);
    BitmapData bmD = null;
    BitmapData bmD2 = null;
    try
    bmD = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
    bmD2 = radar_image.LockBits(new Rectangle(0, 0, radar_image.Width, radar_image.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    IntPtr sc0 = bmD.Scan0;
    unsafe
    int* p = (int*)sc0.ToPointer();
    int* p2 = (int*)bmD2.Scan0.ToPointer();
    for (e = image_clock_area_x; e < image_clock_area_x + image_clock_area_x1; e++)
    for (f = image_clock_area_y; f < image_clock_area_y + image_clock_area_y1; f++)
    Color clock_color = Color.FromArgb(p2[e + f * bmD2.Width]);
    p[e + f * bmD.Width] = clock_color.ToArgb();
    image.UnlockBits(bmD);
    radar_image.UnlockBits(bmD2);
    catch
    try
    image.UnlockBits(bmD);
    catch
    try
    radar_image.UnlockBits(bmD2);
    catch
    int c;
    for (c = 0; c < localImages.Length; c++)
    localImages[c] = new Bitmap(image);
    Bitmap new_image = new Bitmap(Properties.Resources.radar_without_clouds);
    Bitmap new_image1 = new Bitmap(Properties.Resources.radar_without_clouds);
    Bitmap localbmptest = black_and_white(new_image, radar_image);
    Image image1 = black_and_white(new_image, radar_image);
    image1.Save(@"c:\temp\testclouds666.jpg");
    Bitmap clouds = new Bitmap(image1);
    int x;
    int y;
    int a;
    int b;
    int d = 0;
    Bitmap redImage;
    redImage = new Bitmap(512, 512);
    using (Graphics g = Graphics.FromImage(redImage))
    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
    g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
    g.Clear(Color.Red);
    BitmapData bmData = null;
    BitmapData bmData2 = null;
    BitmapData bmDataArray = null;
    try
    bmData = clouds.LockBits(new Rectangle(0, 0, clouds.Width, clouds.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    bmData2 = radar_image.LockBits(new Rectangle(0, 0, radar_image.Width, radar_image.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    IntPtr scan0 = bmData.Scan0;
    IntPtr scan02 = bmData2.Scan0;
    unsafe
    int* p = (int*)scan0.ToPointer();
    int* p2 = (int*)scan02.ToPointer();
    double h, mm;
    for (d = 0; d < localImages.Length; d++)
    bmDataArray = localImages[d].LockBits(new Rectangle(0, 0, localImages[d].Width, localImages[d].Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
    IntPtr scan0Array = bmDataArray.Scan0;
    int* pArray = (int*)scan0Array.ToPointer();
    for (a = 0; a < new_image.Width; a++)
    for (b = 0; b < new_image.Height; b++)
    Color color1 = Color.FromArgb(p[a + b * bmData.Width]);
    Color color2 = Color.FromArgb(p2[a + b * bmData2.Width]);
    if (color1.R != 0 || color1.G != 0 || color1.B != 0)
    h = color2.GetHue();
    mm = RadarAnalysis.Hue2MMPerHour(h);
    if (mm >= treshhold_array[14 - d])
    pArray[a + b * bmDataArray.Width] = color2.ToArgb();
    localImages[d].UnlockBits(bmDataArray);
    clouds.UnlockBits(bmData);
    radar_image.UnlockBits(bmData2);
    catch (Exception error)
    try
    clouds.UnlockBits(bmData);
    catch
    try
    radar_image.UnlockBits(bmData2);
    catch
    try
    localImages[d].UnlockBits(bmDataArray);
    catch
    Logger.Write("Error Exception ==> " + error);
    MessageBox.Show("Error Exception ==> " + error);
    return localImages;
    In the end i'm getting 15 Bitmaps in localImages.
    localImages is Bitmap[]
    The method get a Bitmap and the Bitmap pixel format is: Format8bppIndexed
    I want that in the end the 15 Bitmaps in localImages will be also pixel format of Format8bppIndexed.
    The problem is that if i change everywhere in the method from: PixelFormat.Format32bppArgb to PixelFormat.Format8bppIndexed
    I'm getting exception on the line:
    pArray[a + b * bmDataArray.Width] = color2.ToArgb();
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt
    System.AccessViolationException was unhandled
      HResult=-2147467261
      Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
      Source=My Weather Station
      StackTrace:
           at mws.ImagesComparison.get_images_with_clouds(Bitmap radar_image) in d:\C-Sharp\Download File\Downloading-File-Project-Version-012\Downloading File\ImagesComparison.cs:line 469
           at mws.ScanningClouds.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e) in d:\C-Sharp\Download File\Downloading-File-Project-Version-012\Downloading File\ScanningClouds.cs:line 695
           at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
           at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
           at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
           at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
           at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
           at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
           at System.Threading.ThreadPoolWorkQueue.Dispatch()
           at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
      InnerException: 
    Line 469 is: pArray[a + b * bmDataArray.Width] = color2.ToArgb();

    Thorsten Hi,
    Too complicated for me i will try to look on it.
    Also if you will have time later maybe you could look at it too ? 
    For now what i tried was to get the returned 15 new Bitmaps to a local array:
    bitmaps = ImagesComparison.get_images_with_clouds(b1);
    for (int i = 0; i < bitmaps.Length; i++)
    ConvertTo1or8Bit.ColorToGrayscale(bitmaps[i]);
    break;
    Then make a convertion with a new class trying to convert the Bitmaps to 8 bit in the memory without saving them first to the hard disk. This is the new class:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Drawing.Imaging;
    using System.Drawing;
    using System.IO;
    namespace mws
    class ConvertTo1or8Bit
    public ConvertTo1or8Bit()
    public static Bitmap ColorToGrayscale(Bitmap bmp)
    int w = bmp.Width,
    h = bmp.Height,
    r, ic, oc, bmpStride, outputStride, bytesPerPixel;
    PixelFormat pfIn = bmp.PixelFormat;
    ColorPalette palette;
    Bitmap output;
    BitmapData bmpData, outputData;
    //Create the new bitmap
    output = new Bitmap(w, h, PixelFormat.Format8bppIndexed);
    //Build a grayscale color Palette
    palette = output.Palette;
    for (int i = 0; i < 256; i++)
    Color tmp = Color.FromArgb(255, i, i, i);
    palette.Entries[i] = Color.FromArgb(255, i, i, i);
    output.Palette = palette;
    //No need to convert formats if already in 8 bit
    if (pfIn == PixelFormat.Format8bppIndexed)
    output = (Bitmap)bmp.Clone();
    //Make sure the palette is a grayscale palette and not some other
    //8-bit indexed palette
    output.Palette = palette;
    return output;
    //Get the number of bytes per pixel
    switch (pfIn)
    case PixelFormat.Format24bppRgb: bytesPerPixel = 3; break;
    case PixelFormat.Format32bppArgb: bytesPerPixel = 4; break;
    case PixelFormat.Format32bppRgb: bytesPerPixel = 4; break;
    default: throw new InvalidOperationException("Image format not supported");
    //Lock the images
    bmpData = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly,
    pfIn);
    outputData = output.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.WriteOnly,
    PixelFormat.Format8bppIndexed);
    bmpStride = bmpData.Stride;
    outputStride = outputData.Stride;
    //Traverse each pixel of the image
    unsafe
    byte* bmpPtr = (byte*)bmpData.Scan0.ToPointer(),
    outputPtr = (byte*)outputData.Scan0.ToPointer();
    if (bytesPerPixel == 3)
    //Convert the pixel to it's luminance using the formula:
    // L = .299*R + .587*G + .114*B
    //Note that ic is the input column and oc is the output column
    for (r = 0; r < h; r++)
    for (ic = oc = 0; oc < w; ic += 3, ++oc)
    outputPtr[r * outputStride + oc] = (byte)(int)
    (0.299f * bmpPtr[r * bmpStride + ic] +
    0.587f * bmpPtr[r * bmpStride + ic + 1] +
    0.114f * bmpPtr[r * bmpStride + ic + 2]);
    else //bytesPerPixel == 4
    //Convert the pixel to it's luminance using the formula:
    // L = alpha * (.299*R + .587*G + .114*B)
    //Note that ic is the input column and oc is the output column
    for (r = 0; r < h; r++)
    for (ic = oc = 0; oc < w; ic += 4, ++oc)
    outputPtr[r * outputStride + oc] = (byte)(int)
    ((bmpPtr[r * bmpStride + ic] / 255.0f) *
    (0.299f * bmpPtr[r * bmpStride + ic + 1] +
    0.587f * bmpPtr[r * bmpStride + ic + 2] +
    0.114f * bmpPtr[r * bmpStride + ic + 3]));
    //Unlock the images
    bmp.UnlockBits(bmpData);
    output.UnlockBits(outputData);
    return output;
    But they are still 32 bit. So i guess i didn't realy understand yet how to do it.

  • How to attatch sub vi . can we do it the same way as we call functions in C and return values to the main vi?

    I am creating a Vi. I want to do a sub function. I want to connect a switch to a toggle flip flop so need to  use a push button switch in the input  but at the same time take its output to a true/false loop and execute it according to the ourput of the toggle flip flop which will have an ON and OFF state.
    Jeril

    In the front panel you can r-click the top right icon and "Show Connector". Click which controls and indicator you want to be your interface. Then drag it to your main application and it'll work as a sub-vi. You can do this for all VI's. Just like the "+" VI takes two numbers (controls) and return one result (indicator).
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Creative cloud is working but the webpage cannot find the files and returns a SERVER PROBLEM

    What is wrong since the latest updates of Creative Cloud ??
    The upload is working fine but the Webpage is mostly not reachable and returns a SERVER error.

    I always use the app on my iMac, since more then one year.  The Creative Cloud is then Syncing my files.
    After that I can distribute by making a public link, but since the updates, I can see my folders on the web, but if I enter a folder, then comes a SERVER error.
    In my synced folder on the iMac, the files are marked with the green v whats means, the file is synced withe the cloud.
    Our system is not overloaded, I hev tested it with other dropbox and other cloud sites.

  • My ipod touch used to sync on my old Hp laptop but now it's not even recognized as a device but will still charge on my new asus windows laptop. Itunes on my old laptop is missing something and won't work and I've reinstalled itunes on the HP already.

    My ipod touch used to sync on my old Hp laptop but now it's not even recognized as a device but will still charge on my new asus windows laptop. Itunes on my old laptop is missing something and won't work and I've reinstalled itunes on the HP already. Could somebody please help me to get my ipod touch to sync on the Asus laptop please?!

    Hello hieunguyen2012,
    The following article can help get your iPhone to appear in iTunes on your new laptop.
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    Cheers,
    Allen

  • The songs on my Ipod Classic wont play at all although you can feel and hear the machinery working hard. The tracks are not playng at all but you can see the Ipod rewinding them all and returning to the album. And this happens to the second IPOD I have!

    The songs on my Ipod Classic wont play at all although you can feel and hear the machinery working hard. The tracks are not playng at all but you can see the Ipod rewinding them all and returning to the album. And this happens to the second IPOD I just got!

    First off, I would STRONGLY suggest that a external hard drive would make you life much easier by at least being able to back up your songs on the external drive for when you need them. Even if you don't want them in the iTunes library, you can have them all ready on the external to be re-added as needed. You can get 100's of gigs for under $100 shipped.
    Anyway, since you used Yamipod, are all the songs back on the computer? If so, I would go ahead and restore the iPod, let iTunes then resync everything back to the iPod, then switch it back to manual and see if the restore and resync clears up the issue.
    Patrick

  • I just updated to Adobe Reader 11.0.07 on my Mac 10.6.8 and now the video files don't work.  How do I uninstall the update and return to the previous version?

    I just updated to Adobe Reader 11.0.07 on my Mac OS version 10.6.8 and now the video files don't work.  How do I uninstall the update and return to the previous version?

    I received a notice from Chris Campbell at Adobe that stated : "....we are aware that Macs created between 2006 and 2008 are currently running into problems using the latest release of Flash Player (version 13)."  My question is will the update of Adobe Reader 11.0.07 cause this problem with Flash Player 13 on my Mac?  Sometimes when I try to view streaming video I get sound but no video.
    >

  • How can I uninstall firefox 4 and return to the version prior?

    I would like to uninstall firefox 4 and return to the prior version. how can I do this?

    To downgrade to Firefox 3.6 first uninstall Firefox 4, but do not select the option to "Remove my Firefox personal data". If you select that option it will delete your bookmarks, passwords and other user data.
    You can then install the latest version of Firefox 3.6 available from http://www.mozilla.com/en-US/firefox/all-older.html - it will automatically use your current bookmarks, passwords etc.
    To avoid possible problems with downgrading, I recommend going to your profile folder and deleting the following files if they exist - extensions.cache, extensions.rdf, extensions.ini, extensions.sqlite and localstore.rdf. Deleting these files will force Firefox to rebuild the list of installed extensions, checking their compatibility, and reset toolbar customizations.
    For details of how to find your profile folder see https://support.mozilla.com/kb/Profiles
    What problems are you having with Firefox 4?

Maybe you are looking for