|
This sounds like homework: so I won't give you code!
But...it's pretty easy:
1) Read the two images into Image class instances.
2) Get the graphics context for the "destination" image. (See Graphics.FromImage[^])
3) Draw the smaller image at the appropriate point. (See Graphics.DrawImageUnscaled[^])
4) Dispose of your Graphics context.
5) Save the destination image with the "replaced bit"
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I am not sure whether this is the right forum to ask this question or not. Please let me know if this is not the right forum.
I have list of geo coordinates (the route I took/drive).
Now I want to pass these geo coordinates and get the path/route image from Bing Map service APIs. I am developing a REST service APIs. I am already using the Bing Map Route APIs.
But I am not sure how to get the image of the route/path. I did goole it. I could not find any examples.
Thanks.
|
|
|
|
|
hi.i want to have help for how to impelement one neural network which name is "SOM".does anyone have this code???
|
|
|
|
|
I'm sorry, but we don't give code to people. We expect you to have done some of the work yourself.
|
|
|
|
|
|
I am returning a model to my view on the initial load of a page, the model is populated from the DB, I want to validate the model so that when the user receives the page a validation summary show the errors if any
data in database is coming from ETL system so it can contain invalid data.
whole point is to show error on page load to user if any rather than clicking on submit button and then showing errors
|
|
|
|
|
I didn't see any questions in there.
|
|
|
|
|
I want to validate model on page load in mvc and show error if any.
|
|
|
|
|
That is a requirement. You still haven't ask a question.
|
|
|
|
|
Q is how to validate model on page load/or on HTTPGet request
var uu=TryValidateModel(exceptionData);
this always returns true and Model.IsValid return false only on post not on Get
|
|
|
|
|
You have shown no validation code. How can we tell what the actual issue with your code is?
|
|
|
|
|
That's being mean for the sake of it, Pete. The question is clearly 'how do I validate model on initial request?'.
There may be issues with that question as your subsequent post points out (there's no code presented and we don't even know what platform is in play), but this post was unhelpful.
|
|
|
|
|
BobJanova wrote: That's being mean for the sake of it, Pete. I'm sorry, but I have to disagree with you there. There is no question in the original post. If I were being mean, I'd have downvoted the post but I didn't. However, my point still stood, there was no question in there. Here's the post:nitin_ion wrote: I am returning a model to my view on the initial load of a page, the model is populated from the DB, I want to validate the model so that when the user receives the page a validation summary show the errors if any
data in database is coming from ETL system so it can contain invalid data.
whole point is to show error on page load to user if any rather than clicking on submit button and then showing errors That is a requirement, not a question. Of course, I could have made assumptions as to what was supposed to have been asked, but they would have been assumptions. So, it's great that you have the benefit of the subsequent posts to get the context to judge me, but I didn't have that context. All I could see at that point was a request for someone to do the work and not a question on how to solve the problem.
|
|
|
|
|
It's no less of a question than the one about TIFF and file copying just below. Okay, that one has 'How do I solve this problem?' explicitly, but whenever a thread starter is a description of a problem, that's the implicit question. It might be a bad implicit question, in which case tell the questioner what is wrong with it (or downvote and move on).
Anyway, don't mean to start a fight about this but just stating my opinion on dealing with problem descriptions in these forums.
|
|
|
|
|
OK, so after reading this thread and figuring out (I hope!) what you're really trying to do, my question is WHY??
This is an out-bound model going to the client on a GET request, not a POST. Soooo, I fail to see why you have to validate a model your sending to the client?? If you have to do this, your business rules are messed up because the data in your model should ALWAYS be valid.
You normally validate a model in-bound from the client, not out-bound.
Yeah, I see the you said your data is coming from an ETL system, so, again, your business logic should be checking this, not your UI code.
|
|
|
|
|
I have an event that is subscribed by multiple pages created by a page factory. All the pages are similar except for the title and items in a list. What I would like to do is when the event fires, only the page that is currently on display should act on the event whereas the other pages either should ignore it or not get it in the first place. The app is created on the .NET compact framework which is a limited subset of the full framework.
Any help is appreciated.
|
|
|
|
|
Hi ,
I have faced one issue on my project. One of our application is doing rename and Copy operation for tiff image from one location to another location in the server itself. I mean, in the Server D drive, copy the file from one directory to another directory.
The issue is:
Daily around thousands of images will be copied. Last week, One Tiff Image file length is differed from the original. The copied file has extra bytes. So the original and copied image size difference is 8bytes. I compared with WinMerge tool. Some bytes added at the end of the file.
Do you know the reason for this problem?. The server is Window 2008R2. Application build with .Net Framework 4.0.
|
|
|
|
|
cravi85 wrote: Do you know the reason for this problem? The first place I'd look is the source code of the application.
/ravi
|
|
|
|
|
This is the code file. I added onlymain thing. Other manipulations are confidential. So i am sorry for not able to give full code. But this part only related to file operation.
Major methods are ,
File.move , File.Copy.
This is Parellal Process. So i am using Parellal method.
The source code as below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Timers;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace AccessSharedFiles
{
public partial class Parellal : Form
{
public Queue queBatch;
public System.Timers.Timer DurationForCopy;
public System.Timers.Timer DurationForProcess;
public bool currentlyProcessing = true;
public bool currentlyCopying = true;
public Parellal()
{
InitializeComponent();
}
private void Parellal_Load(object sender, EventArgs e)
{
try
{
queBatch = new Queue();
DurationForCopy = new System.Timers.Timer();
DurationForCopy.Interval = 5 * 1000;
DurationForCopy.Enabled = true;
DurationForCopy.Elapsed += new ElapsedEventHandler(CopyFiles);
DurationForProcess = new System.Timers.Timer();
DurationForProcess.Interval = 5 * 1000;
DurationForProcess.Enabled = true;
DurationForProcess.Elapsed += new ElapsedEventHandler(ProcessFiles);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void CopyFiles(object sender, EventArgs eArgs)
{
try
{
if (currentlyCopying)
{
currentlyCopying = false;
string[] files = Directory.GetFiles( @"C:\SDU\SDU_Parel\Source\");
foreach (string fi in files)
{
File.Move(fi, @"C:\SDU\SDU_Parel\Intermediate\" + fi.Split('\\')[fi.Split('\\').Length - 1].Split('.')[0] + ".tif");
PutFolderinQueue(fi.Split('\\')[fi.Split('\\').Length - 1].Split('.')[0] + ".tif");
break;
}
}
currentlyCopying = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
currentlyCopying = true;
}
}
private void PutFolderinQueue(string fileName)
{
try
{
string strVal = fileName.ToString();
Monitor.Enter(queBatch);
queBatch.Enqueue(fileName);
Monitor.Exit(queBatch);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void ProcessFiles(object sender, EventArgs eArgs)
{
try
{
if (currentlyProcessing)
{
currentlyProcessing = false;
List<string> al = new List<string>();
Monitor.Enter(queBatch);
if (queBatch.Count > 0)
{
for (int intCount = 1; intCount <= queBatch.Count; intCount++)
al.Add(queBatch.Dequeue().ToString().Trim());
}
Monitor.Exit(queBatch);
Parallel.ForEach(al, name => { ProcessBatch(name); });
if (al != null)
{
al = null;
}
currentlyProcessing = true;
GC.Collect();
}
}
catch (Exception ex)
{
currentlyProcessing = true;
MessageBox.Show(ex.Message);
}
}
private void ProcessBatch(string ivalue)
{
try
{
File.Copy(@"C:\SDU\SDU_Parel\Intermediate\"+ivalue, @"C:\SDU\SDU_Parel\Destination\" + ivalue);
File.Delete(@"C:\SDU\SDU_Parel\Intermediate\" + ivalue);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
|
|
|
|
|
Some more information.
The above code will do as below:
Tiff Image File will be transferred continuously from one location to this server(Inside Source folder). My application will pick files from source folder for every 5 secs and move to Intermediate folder. After this file will be read by some confidential code. then this image file will be copied to Destination folder.
Last 1 year ,this process was working without any issue. But last week, TWO Image files had issue. These two file's size is greater than the original file.
The file 1:
Source folder: 1756 bytes
Destination folder : 1764 bytes
The file 2:
Source folder :26525 bytes
Destination Folder : 26529 bytes
I should not upload the tiff images because of some confidential code.
|
|
|
|
|
The right thing to do (IMHO) is to try to isolate the problem. I suggest writing a simple app that just copies one of the files. Use a hardcoded value for ivalue in the following fragment:
string ivalue = ...;
File.Copy(@"C:\SDU\SDU_Parel\Intermediate\"+ivalue, @"C:\SDU\SDU_Parel\Destination\" + ivalue);
File.Delete(@"C:\SDU\SDU_Parel\Intermediate\" + ivalue);
I honestly see no reason why the file sizes should be different. Are you sure you're examining the actual file length(s) and not the allocated sizes (which can differ based on sector size)? Wait, ignore that. Your source and destination devices are the same, and should have the same sector size.
/ravi
|
|
|
|
|
There's nothing here that should be changing file contents, unless there's a bug in File.Copy and I'd think that would have been found if it were the case (it must be one of the most commonly used Framework methods).
Does your application code open write streams on the intermediate file? I'd be pretty sure that your problem lies in there, almost certainly in a 'read, modify, write' byte array copy operation that doesn't check the read length properly.
|
|
|
|
|
Thanks for assisting me.
Intermediate code will do the some operation but last 1.5 years it was going fine.We recently added the Parallel.each concept instead of ordinary FOR LOOP for performance issue. So now this program utilize all the CPU core. I think , this area may be the cause.
But i tested with this code also. not helpful
|
|
|
|
|
This depends entirely on the code that is copying the files. Since you don't show that code, it's impossible to tell you what's going wrong.
|
|
|
|
|
please see the previous post. i have given my source code. thanks for your great assistance..
|
|
|
|